/Usr/Bin/Ld: Cannot Find -Lglut

glui /usr/bin/ld: cannot find -lXmu

The answer was actually one of the first ones here originally but the owner deleted it, it seems. I was able to solve the problem by creating a symbolic link to the latest version of the library (i.e. /usr/lib/libXmu.so.6) and compile the code successfully.

Linker won't find -lglut

Which Linux are you using? It looks like you're using a 64-bit system, but trying to compile a 32-bit application (because of -m32 compiler switch). So either remove the -m32 or install the 32-bit development libraries. They may be named like freeglut-32bit or something like that.

Error with GLUT compile in ubuntu

The GCC linker may scan libraries in the order they are on the command line, which means for you it may scan the libraries first and sees no one using them, and therefore you get the errors. To be sure, place the libraries last on the command line:

gcc hw_opengl.cpp -o hw_opengl -lGL -lGLU -lglut

Can't link opengl libraries in makefile

Makefiles can be a bit arcane, somewhat fussy to get right, and there's a lot of voodoo floating around about how to write them. Here is a more reasonable, fixed-up makefile:

# Don't set CC=gcc, because it's not 1995 any more.
ASMBIN = nasm
# CFLAGS is for C, CXXFLAGS is for C++
# Also, let's put -g here
CXXFLAGS = -m32 -Wall -g
LDFLAGS = -m32

# Use pkg-config wherever possible
opengl_libs := -lglut $(shell pkg-config --libs gl glu)
opengl_cflags := $(shell pkg-config --cflags gl glu)

all: main

main: main.o a_t.o
# Order of flags is important here!
# We also have to use CXX instead of CC to avoid linker errors.
$(CXX) $(LDFLAGS) -o $@ $^ $(opengl_libs)

a_t.o:
$(ASMBIN) -f elf a_t.asm

main.o: main.cc data.cc
# Don't forget -c and -o
$(CXX) $(CXXFLAGS) $(opengl_cflags) -c $< -o $@

clean:
# Should be *.o, not *o
rm -rf *.o main

.PHONY: all clean

However, this probably won't fix the error you are running into. You need to remember to install the development version of the OpenGL libraries. On Debian-based systems, this would mean installing the following packages (for i386, of course):

  • libglu1-mesa-dev
  • libgl1-mesa-dev
  • freeglut3-dev.

The pkg-config program is probably already installed.



Related Topics



Leave a reply



Submit