Reputation: 1253
I have the following makefile that uses C++ and OpenGL. It was compiling at all, so I added the -m32 line in order to attempt to get it to compile in x86_64. Now I'm getting the same error but it's saying i386 instead.
What can I do to get this program to compile?
I'm running OSX 10.8, just in case that makes a difference.
Thank you all.
.SUFFIXES: .cpp
#Change the following two lines to reflect the locations
# of the GLUT library (.a) and includes on your system
#TOP = /pool/u/class/cs520/Mesa-7.0.3
CFLAGS = -w -s -O2 -ansi -DSHM
XLIBS = -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE
LIBS = -lglut -lGLU -lGL
#INCLS = -I/usr/X11R/include -I/share/mesa/include #-I$(TOP)/include
INCLS = -I/usr/X11R6/include -I/usr/X11/include/GL
LIBDIR = -L/usr/X11/lib -L/usr/X11R6/lib #-L$(TOP)/lib
#GLUT_LIB_LOCATION=/usr/X11R6/lib
#GLUT_INC_LOCATION=/usr/X11R6/include
#CC=gcc
CC=g++
#CPPFLAGS=-I${GLUT_INC_LOCATION} #-w
#GLLIBS=-L${GLUT_LIB_LOCATION} -lglut -lGL -lGLU
#LPATH=${GLUTPATH}
INCS=
libs = ${GLLIBS} -lm
All: terrain
terrain: tg.o tga.o terrain.o
$(CC) $(LPATH) tg.o tga.o terrain.o -m32 ./glui/libglui.a $(libs) -o terrain $(LIBDIR) $(LIBS) $(XLIBS)
.cpp.o:
$(CC) -c -D_LINUX_ $(INCS) $*.cpp $(INCLS)
clean:
rm *.o
tg.o: tg.cpp terrain.h tga.h glui.h
tga.o: tga.cpp tga.h
terrain.o : terrain.cpp terrain.h
And I'm getting the following error.
g++ -c -D_LINUX_ tga.cpp -I/usr/X11R6/include -I/usr/X11/include/GL
g++ -c -D_LINUX_ terrain.cpp -I/usr/X11R6/include -I/usr/X11/include/GL
g++ tg.o tga.o terrain.o -m32 ./glui/libglui.a -lm -o terrain -L/usr/X11/lib -L/usr/X11R6/lib -lglut -lGLU -lGL -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE
ld: warning: ld: warning: ld: warning: ignoring file tg.o, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 1 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): tg.oignoring file terrain.o, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 1 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): terrain.oignoring file tga.o, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 1 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): tga.o
ld: warning: ignoring file ./glui/libglui.a, file was built for archive which is not the architecture being linked (i386): ./glui/libglui.a
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [terrain] Error 1
Upvotes: 1
Views: 2236
Reputation: 162164
You're compiling for MacOS X so don't use X11 but the native OpenGL Framework; the compiler/linker option is -framework OpenGL
.
And the error you have stems from that you probably took precompiled library filed not even compiled for your particular version of MacOS X, if even MacOS X at all. No compiler switch will help you there.
Upvotes: 1