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
Building Subversion 1.5.4 on Debian: Could Not Find Library Containing Rsa_New
Linux Shell Script - Find All Files and Run a Command on Each One of Them
Git Wont Reset File Permissions Over Cifs Mount
Different Pulic Key for Jump Host and Destination Host Over Ssh
Linux Script Telnet Head Request
Would Gcc 4.8 and 4.7 Peacefully Coexist on The Same Machine
Why a Static Library Can Depend on a Shared a Library
Gitlab: You Are Not Allowed to Access Master! After Moving Gitlab to Another Server
How to Programmatically Know If I Am in a Vm
How Is The Linux Calculating Memfree
Linux Compile for Enable Uart2
Eclipse Kura Installation on Raspberry Pi 3
Extract/See Content of a Specific File Inside a .War File
Tcp Keepalive - Protocol Not Available