SO.
I’m a little new to the Linux dev world (without an ide), so please be patient.
The Issue
I have a make file constructed which compiles about 7-8 files into .o files which are then linked together with a few libraries. I have done locates on these libraries, and their dev counterparts do exist. The problem is that the linker refuses to find them. My output (if I am reading this correctly) tells me that it’s looking in the wrong area. I’ve exported my LD_PATH to include /usr/lib, which is where my .so. files are. My main question is, how do I get -lglew and -lglut to link up with each other? I would also like to put my .o files in my obj folder and my binaries in a bin folder. Is this possible in a makefile? If so, given my make file, what would be the best recipe to do this?
The Makefile
1 BIN = bin/
2 OBJ = obj/
3 TARGET = opengl_03
4 DEPS = main.o displayinit.o initializer.o algorithms.o matrix3f.o window.o vertex3.o
5 CC = g++
6 CFLAGS = -g -m32
7 LIBS = -lglut -lGLEW
8 INCLUDEPATH = -L/usr/include/ -L/usr/lib
9
10 $(TARGET) : $(DEPS)
11 $(CC) $(LIBS) $(INCLUDEPATH) $(CFLAGS) -o $(TARGET) $(DEPS) $(BIN)
12
13 displayinit.o : displayinit.cpp displayinit.h
14 $(CC) -c displayinit.cpp $(OBJ)
15 initializer.o : initializer.cpp initializer.h
16 $(CC) -c initializer.cpp $(OBJ)
17 algorithms.o : algorithms.cpp algorithms.h
18 $(CC) -c algorithms.cpp $(OBJ)
19 matrix3f.o : matrix3f.cpp matrix3f.h
20 $(CC) -c matrix3f.cpp $(OBJ)
21 vertex3.o : vertex3.cpp vertex3.h
22 $(CC) -c vertex3.cpp $(OBJ)
23 window.o : window.cpp window.h
24 $(CC) -c window.cpp $(OBJ)
25 main.o : main.cpp
26 $(CC) -c main.cpp $(OBJ)
27
28 clean:
29 rm $(DEPS)
30
31
Output
g++ -lglut -lGLEW -L/usr/include/ -L/usr/lib -g -m32 -o opengl_03 main.o displayinit.o initializer.o algorithms.o matrix3f.o window.o vertex3.o bin/
/usr/bin/ld: skipping incompatible /usr/lib/libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.a when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../libglut.a when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.so when searching for -lglut
/usr/bin/ld: skipping incompatible /usr/lib/libglut.a when searching for -lglut
/usr/bin/ld: cannot find -lglut
/usr/bin/ld: cannot find -lGLEW
/usr/bin/ld: cannot find bin/: File format not recognized
collect2: ld returned 1 exit status
make: *** [opengl_03] Error 1
I appreciate the assistance.
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.