OSX:文件是为存档而构建的,而不是链接的体系结构(i386)

时间:2013-04-23 01:20:55

标签: macos g++

我有以下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) 

我收到以下错误:

    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

如何避免以下错误:

如果重要的话,我正在使用OSX。

File was built for archive which is not the architecture being linked (i386)

提前致谢。

1 个答案:

答案 0 :(得分:1)

对于GlutRenderer.o,SceneDescription.o,RayTraceData.o文件:将它们添加到干净的部分make clean。目前您只清理一个文件:tracecone.o。在将-m32标志添加到makefile之前,可能还构建了其他目标文件。您也可以手动删除所有目标文件 在源根目录中运行find . | grep '\.o$'以检查清理后是否还有任何目标文件。

对于libraygraph.a和libvrmath.a:那些libs也必须用-m32标志构建。