Mac OS X 下命令行编译错误: ld: library not found for -lcrt1.10.6.o

在 Mac OS X 的 10.8.3 的版本中,使用命令行运行 configure 时,生成下面的错误:

WenBi-MacBook:tcpdump-4.4.0 wenbi$ ./configure
checking build system type... x86_64-apple-darwin12.3.0
checking host system type... x86_64-apple-darwin12.3.0
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/wenbi/Downloads/tcpdump-4.4.0':
configure: error: C compiler cannot create executables
See `config.log' for more details


查看 config.log 文件的内容,会看到更详情的错误信息:

configure:2755: gcc    conftest.c  >&5
 81 ld: library not found for -lcrt1.10.6.o
 82 collect2: ld returned 1 exit status
 83 configure:2759: $? = 1
 84 configure:2797: result: no
 85 configure: failed program was:
 86 | /* confdefs.h */
 87 | #define PACKAGE_NAME ""
 88 | #define PACKAGE_TARNAME ""
 89 | #define PACKAGE_VERSION ""
 90 | #define PACKAGE_STRING ""
 91 | #define PACKAGE_BUGREPORT ""
 92 | #define PACKAGE_URL ""
 93 | /* end confdefs.h.  */
 94 |
 95 | int
 96 | main ()
 97 | {
 98 |
 99 |   ;
100 |   return 0;
101 | }
102 configure:2802: error: in `/Users/wenbi/Downloads/tcpdump-4.4.0':
103 configure:2804: error: C compiler cannot create executables

上面用红色标注的信息,说明 gcc 编译器找不到 C 的运行时库。这是因为没有把 xocde 提供的头文件目录和库目录使用环境变量导出,在命令行中使用 gcc 时,找不到相应的标准头文件和库文件。

打开用户目录下的 .bash_profile 文件,添加如下内容:

export C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include
export LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib

重新运行一个新的 bash 窗口,重新运行 configure/make/make install。 

你可能感兴趣的:(其它)