编译选项-fPIC时出现Gcc错误



我正在读一本书,但在使用此代码进行编译时遇到了一个错误。

$ rm -f injection.dylib
$ export PLATFORM=/Developer/Platforms/iPhoneOS.platform
$ $PLATFORM/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 
-c -o injection.o injection.c 
-isysroot $PLATFORM/Developer/SDKs/iPhoneOS5.0.sdk  -fPIC
$ $PLATFORM/Developer/usr/bin/ld  -dylib -lsystem -lobjc 
-o injection.dylib injection.o 
-syslibroot $PLATFORM/Developer/SDKs/iPhoneOS5.0.sdk/

我遇到了一些麻烦,尤其是在这一行:

$PLATFORM/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 
-c -o injection.o injection.c 
-isysroot $PLATFORM/Developer/SDKs/iPhoneOS5.0.sdk  -fPIC

这是错误

 arm-apple-darwin10-llvm-gcc-4.2:  -fPIC: No such file or directory

我该如何解决。。。这意味着什么?

这意味着您键入了错误的命令行:

stieber@gatekeeper:~$ gcc  -fPIC
gcc: error:  -fPIC: No such file or directory
gcc: fatal error: no input files
compilation terminated.

行中间的\似乎使gcc(可能还有llvm-gcc)停止将参数视为选项,并始终将它们视为文件名。

stieber@gatekeeper:~$ gcc -fPIC
gcc: fatal error: no input files
compilation terminated.

给出了预期的结果。

最新更新