I have the following makefile:
PROG = tracecone
RBASE= /Users/owner/Documents/raytrace
GDIR=$(RBASE)/Graphics
MDIR=$(RBASE)/VrMath
ODIR=$(RBASE)/OpenglRender
MANDIR=$(RBASE)/RaytraceMgr
CFLAGS = -w -s -O2 -ansi -DSHM -m32
XLIBS = -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE
LIBS = -lglut -lGLU -lGL
RAYLIBS = -lraygraph -lvrmath
INCLS = -I/usr/X11R6/include -I/usr/X11/include/GL
INCL1 = -I$(GDIR) -I../RayTrace -I$(GDIR) -I$(MDIR) -I$(ODIR) -I$(MANDIR)
LIBDIR = -L/usr/X11/lib -L/usr/X11R6/lib -L$(GDIR) -L$(MDIR)
#source codes
SRCS = $(PROG).cpp
#substitute .cpp by .o to obtain object filenames
OBJS = $(SRCS:.cpp=.o)
#in ../Graphics
OBJOD = $(ODIR)/GlutRenderer.o
OBJO = GlutRenderer.o
OBJMAND = $(MANDIR)/SceneDescription.o
OBJMAN = SceneDescription.o
OBJ_temp = ../RayTrace/RayTraceData.o
#$< evaluates to the target's dependencies,
#$@ evaluates to the target
$(PROG): $(OBJS)
g++ -o $@ -m32 $(OBJ_temp) $(OBJS) $(OBJOD) $(OBJMAND) $(LIBDIR) $(LIBS) $(XLIBS) $(RAYLIBS)
$(OBJS):
g++ -c -m32 $*.cpp $(INCLS) $(INCL1)
$(OBJ1):
cd $(GDIR); g++ -m32 -c $*.cpp $(INCLS)
$(OBJM):
cd $(MDIR); g++ -m32 -c $*.cpp $(INCLS)
$(OBJO):
cd $(ODIR); g++ -m32 -c $*.cpp $(INCLS)
$(OBJMAN):
cd $(MANDIR); g++ -m32 -c $*.cpp $(INCLS)
clean:
rm $(OBJS)
clean1:
rm $(OBJD1)
And I'm getting the following error:
g++ -c -m32 tracecone.cpp -I/usr/X11R6/include -I/usr/X11/include/GL -I/Users/owner/Documents/raytrace/Graphics -I../RayTrace -I/Users/owner/Documents/raytrace/Graphics -I/Users/owner/Documents/raytrace/VrMath -I/Users/owner/Documents/raytrace/OpenglRender -I/Users/owner/Documents/raytrace/RaytraceMgr
g++ -o tracecone -m32 ../RayTrace/RayTraceData.o tracecone.o /Users/owner/Documents/raytrace/OpenglRender/GlutRenderer.o /Users/owner/Documents/raytrace/RaytraceMgr/SceneDescription.o -L/usr/X11/lib -L/usr/X11R6/lib -L/Users/owner/Documents/raytrace/Graphics -L/Users/owner/Documents/raytrace/VrMath -lglut -lGLU -lGL -lX11 -lXext -lXmu -lXext -lXmu -lXt -lXi -lSM -lICE -lraygraph -lvrmath
ld: warning: ld: warning: ld: warning: ignoring file /Users/owner/Documents/raytrace/OpenglRender/GlutRenderer.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Users/owner/Documents/raytrace/OpenglRender/GlutRenderer.oignoring file /Users/owner/Documents/raytrace/RaytraceMgr/SceneDescription.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /Users/owner/Documents/raytrace/RaytraceMgr/SceneDescription.oignoring file ../RayTrace/RayTraceData.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): ../RayTrace/RayTraceData.o
ld: warning: ignoring file /Users/owner/Documents/raytrace/Graphics/libraygraph.a, file was built for archive which is not the architecture being linked (i386): /Users/owner/Documents/raytrace/Graphics/libraygraph.a
ld: warning: ignoring file /Users/owner/Documents/raytrace/VrMath/libvrmath.a, file was built for archive which is not the architecture being linked (i386): /Users/owner/Documents/raytrace/VrMath/libvrmath.a
Undefined symbols for architecture i386:
"_BackgroundColorR3", referenced from:
RayTrace(int, VectorR3 const&, VectorR3, VectorR3&, long)in tracecone.o
"_Cdims", referenced from:
ResizeWindow(int, int)in tracecone.o
"_GlobalAmbientR3", referenced from:
CalcAllDirectIllum(VectorR3 const&, VisiblePoint const&, VectorR3&, long)in tracecone.o
RenderWithGlut() in tracecone.o
"_LightArray", referenced from:
CalcAllDirectIllum(VectorR3 const&, VisiblePoint const&, VectorR3&, long)in tracecone.o
RenderWithGlut() in tracecone.o
"_MainView", referenced from:
ResizeWindow(int, int)in tracecone.o
mySpecialFunc(int, int, int)in tracecone.o
SetupRayTraceWorld() in tracecone.o
RayTraceView() in tracecone.o
RenderWithGlut() in tracecone.o
"_NumLights", referenced from:
CalcAllDirectIllum(VectorR3 const&, VisiblePoint const&, VectorR3&, long)in tracecone.o
RenderWithGlut() in tracecone.o
"_NumObjects", referenced from:
SeekIntersection(VectorR3 const&, VectorR3 const&, double*, VisiblePoint&, long)in tracecone.o
ShadowFeeler(VectorR3 const&, Light const&, long)in tracecone.o
SetupRayTraceWorld() in tracecone.o
RenderWithGlut() in tracecone.o
"_ViewObj", referenced from:
SeekIntersection(VectorR3 const&, VectorR3 const&, double*, VisiblePoint&, long)in tracecone.o
ShadowFeeler(VectorR3 const&, Light const&, long)in tracecone.o
SetupRayTraceWorld() in tracecone.o
RenderWithGlut() in tracecone.o
"SetUpLights()", referenced from:
SetupRayTraceWorld() in tracecone.o
"SetUpMainView()", referenced from:
SetupRayTraceWorld() in tracecone.o
"SetUpMaterials()", referenced from:
SetupRayTraceWorld() in tracecone.o
"DirectIlluminateViewPos(VectorR3 const&, VectorR3 const&, VectorR3 const&, Light const&, MaterialBase const&, VectorR3&, VectorR3 const&)", referenced from:
DirectIlluminateViewPos(VisiblePoint const&, VectorR3 const&, Light const&, VectorR3&, VectorR3 const&)in tracecone.o
"GetOrtho(VectorR3 const&, VectorR3&, VectorR3&)", referenced from:
ViewableCone::SetCenterAxis(VectorR3 const&) in tracecone.o
"CameraView::RotateViewUp(double)", referenced from:
mySpecialFunc(int, int, int)in tracecone.o
"CameraView::PixelDirPreCalc()", referenced from:
CameraView::SetDirection(VectorR3 const&) in tracecone.o
CameraView::SetDirection(float const*)in tracecone.o
CameraView::SetDirection(double const*)in tracecone.o
CameraView::SetDirection(double, double, double)in tracecone.o
"CameraView::RecalcPixeldUdV()", referenced from:
CameraView::SetScreenDimensions(double, double)in tracecone.o
CameraView::SetScreenPixelSize(int, int)in tracecone.o
"CameraView::RotateViewRight(double)", referenced from:
mySpecialFunc(int, int, int)in tracecone.o
"CameraView::CalcScreenCenter()", referenced from:
CameraView::SetPosition(VectorR3 const&) in tracecone.o
CameraView::SetPosition(float const*)in tracecone.o
CameraView::SetPosition(double const*)in tracecone.o
CameraView::SetPosition(double, double, double)in tracecone.o
CameraView::SetDirection(VectorR3 const&) in tracecone.o
CameraView::SetDirection(float const*)in tracecone.o
CameraView::SetDirection(double const*)in tracecone.o
...
"CameraView::RescaleDistanceOfViewer(double)", referenced from:
mySpecialFunc(int, int, int)in tracecone.o
"PixelArray::ClampAndDrawFloats()", referenced from:
PixelArray::Draw() in tracecone.o
"PixelArray::SetSize(int, int)", referenced from:
ResizeWindow(int, int)in tracecone.o
PixelArray::PixelArray(int, int)in tracecone.o
"GlutRenderer::RenderViewable(ViewableBase const&)", referenced from:
RenderWithGlut() in tracecone.o
"GlutRenderer::FinishRendering()", referenced from:
RenderWithGlut() in tracecone.o
"GlutRenderer::SetupCameraView(CameraView const&, double, double)", referenced from:
RenderWithGlut() in tracecone.o
"GlutRenderer::SetGlobalAmbientLight(VectorR3 const&)", referenced from:
RenderWithGlut() in tracecone.o
"GlutRenderer::SetGlobalAmbientLight(double, double, double)", referenced from:
RenderWithGlut() in tracecone.o
"GlutRenderer::AddLight(Light const&)", referenced from:
RenderWithGlut() in tracecone.o
"GlutRenderer::GlutRenderer()", referenced from:
RenderWithGlut() in tracecone.o
"Material::Default", referenced from:
ViewableCone::Reset() in tracecone.o
"ViewableBase::CalcExtentsInBox(AABB const&, AABB&) const", referenced from:
vtable for ViewableBasein tracecone.o
"ViewableBase::CalcAABB(AABB&) const", referenced from:
vtable for ViewableBasein tracecone.o
"Material::CalcLocalLighting(VectorR3&, Light const&, VectorR3 const&, double, VectorR3 const&, VectorR3 const&, VectorR3 const&, VectorR3 const*) const", referenced from:
vtable for Materialin tracecone.o
"Material::Clone() const", referenced from:
vtable for Materialin tracecone.o
"vtable for ViewableCone", referenced from:
ViewableCone::ViewableCone()in tracecone.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [tracecone] Error 1
How can I avoid the following error:
I'm using OSX, if that matters.
File was built for archive which is not the architecture being linked (i386)
Thanks in advance.
For the GlutRenderer.o, SceneDescription.o, RayTraceData.o files: add them to your clean section and
make clean
. For now you are cleaning only one file: tracecone.o. Perhaps other object files were built before you added-m32
flag to your makefile. You can also remove all object files manually.Run
find . | grep '\.o$'
in source root directory to check if there is any object file left after the cleaning.For the libraygraph.a and libvrmath.a: those libs must be built with
-m32
flag too.