c++ - 操作系统 : Symbols not found for architecture i386

标签 c++ macos opengl glui

我有以下使用 C++ 和 OpenGL 的生成文件。它正在编译,所以我添加了 -m32 行以尝试让它在 x86_64 中编译。现在我遇到了同样的错误,但它说的是 i386。

我该怎么做才能编译这个程序?

我正在运行 OSX 10.8,以防万一。

谢谢大家

.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

我收到以下错误。

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

最佳答案

您正在为 MacOS X 编译,所以不要使用 X11,而是使用 native OpenGL 框架;编译器/链接器选项是 -framework OpenGL

你的错误源于你可能使用了预编译库文件,甚至没有为你的特定版本的 MacOS X 编译,甚至根本没有编译。没有编译器开关可以帮助您。

关于c++ - 操作系统 : Symbols not found for architecture i386,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16630270/

相关文章:

C++如何识别变量的类型

c++ - 如何控制 MediaFoundation 中的相机捕获显示?

objective-c - NSWindow 注册鼠标事件(使用 NSTrackingArea),即使应用程序未获得焦点?

java - LWJGL 基础 : Drawing Quads At Depth

c++ - C++ 中的常量函数

c++ - 从数组中提取数字的高效算法

xcode - 在 OS X 10.10 (Yosemite) 下编译 VLCKit

xcode - 沙箱无法访问本地套接字

c++ - 我应该使用相同的 VBO 来传递不同的顶点属性吗?或者我应该使用 2?

c++ - 为什么要为一个属性指定不同的顶点格式?