1

我正在尝试将 Eclipse C++ 和 Irrlicht 用于学校的一个项目。我的问题是设置操作环境。

我用过这个http://irrlicht3d.org/wiki/index.php?n=Main.Macintosh

我正在使用新的 MacBook Pro。

我认为错误在这个标志中。 在此处输入图像描述

**** Build of configuration Debug for project HalloWorld2 ****

make all 
Building file: ../src/helloworld.cpp
Invoking: GCC C++ Compiler
g++ -I/Users/JAMES/Code/irrlicht-1.7.2/include -O0 -g3 -Wall -c -fmessage-length=0 -arch i386 -fvisibility=hidden -MMD -MP -MF"src/helloworld.d" -MT"src/helloworld.d" -o "src/helloworld.o" "../src/helloworld.cpp"
Finished building: ../src/helloworld.cpp

Building target: HalloWorld2
Invoking: MacOS X C++ Linker
g++ -L/Users/JAMES/Code/irrlicht-1.7.2/source/Irrlicht/MacOSX/build/Release -L/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib -Xlinker -arch i386 -framework OpenGL -framework Carbon -framework Cocoa -framework IOKit -o "HalloWorld2"  ./src/helloworld.o   -lIrrlicht
i686-apple-darwin11-llvm-g++-4.2: i386: No such file or directory
make: *** [HalloWorld2] Error 1
4

1 回答 1

1

The problem comes from the use of -Xlinker to pass arguments to the linker. The man page of g++ says:

-Xlinker option

Pass option as an option to the linker. You can use this to supply system-specific linker options which GCC does not know how to recognize.

If you want to pass an option that takes an argument, you must use -Xlinker twice, once for the option and once for the argument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions. It does not work to write -Xlinker "-assert definitions", because this passes the entire string as a single argument, which is not what the linker expects.

Here -Xlinker appears only once whereas it should be appear between each argument sent to the linker. So a ugly solution is to write:

-arch -Xlinker i386 -Xlinker -framework -Xlinker OpenGL -Xlinker -framework -Xlinker Carbon -Xlinker -framework -Xlinker Cocoa -Xlinker -framework -Xlinker IOKit

But if you find a way to configure Eclipse to use -Wl, instead of -Xlinker it would be better I think:

-Wl,option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.

Then you could use:

-arch,i386,-framework,OpenGL,-framework,Carbon,-framework,Cocoa,-framework,IOKit
于 2012-02-19T18:07:36.630 回答