Skip to content

Linking errors: undefined reference to glBendFunc, glGetError, sincosf, etc. #1

@AlbertoGP

Description

@AlbertoGP

I do not paste the error output because it’s just a bunch of “undefined reference to ...” lines, but I can reproduce it and paste it here if needed.

This is on Pop_OS 22.04 LTS, based on Ubuntu 22.04 LTS.

The issue seems to be the order in which the linking is done at line 74 in the Makefile:
@$(LD) $(LDFLAGS) $(OFILES) -o $@ -Wl,-Map=$(@:.elf=.map)
Which expands to:
gcc -Wl,-x -Wl,--gc-sections -lglut -lm -lGL -O3 -g main.o mtx.o shader.o main.frag.o main.vert.o -o veles.elf -Wl,-Map=veles.map

The correct order, as far as I know, is to have the libraries after the object files, like this:
gcc main.o mtx.o shader.o main.frag.o main.vert.o -Wl,-x -Wl,--gc-sections -lGL -lglut -lm -O3 -g -o veles.elf -Wl,-Map=veles.map

I’m preparing the pull request that fixes it in this system, it’s just swapping LDFLAGS and OFILES.

Could this be specific to this system? Does it link correctly in other Linux distributions or with other compilers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions