Need help with link library path

I’m trying to build an example go-fltk program.
The linker is complaining it can’t find my GLU library. libGLU.so.1 is found on my machine at /usr/lib64/
I have tried running go build -ldflags="-L /usr/lib64/" main.go without success. Have I got the format of the command wrong?

Hi @shakeshuck,

A quick guess: Try -L without a space:

go build -ldflags="-L/usr/lib64/" 

If this does not help, what’s the exact error message?

Morning, Christoph.

Without the space, it says:

flag provided but not defined: -L/usr/lib64

With the space, the full error is:

/usr/lib64/go/1.22/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
/usr/lib64/gcc/x86_64-suse-linux/13/…/…/…/…/x86_64-suse-linux/bin/ld: cannot find -lGLU: No such file or directory
collect2: error: ld returned 1 exit status

Thanks for looking.

I doubt it’s related to the path.
You have libGLU.so.1, but the linker will look for libGLU.so

On many linux distrubutions those are in different packages.
On my ubuntu 22.04, libGLU.so.1 is in libglu1-mesa
While libGLU.so is in libglu1-mesa-dev.

The -dev package is required to build anything that links to libGLU

Or, since libGLU.so is just a symlink to libGLU.so.1 you may also get away with creating that symlink

That’s it. You’ve cracked it.
The package I needed on openSuse was glu-devel.

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.