【发布时间】:2015-01-26 18:22:10
【问题描述】:
所以,我升级到 Yosemite 并将 gcc 更新到 gcc-4.9。现在没有任何效果。即使是这样的基本 C 程序:
#include "stdio.h"
void main() {
printf("woh!");
}
gcc -v a.c的详细信息如下。基本错误是:
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
这是我对 CC、clang 和 gcc 的配置。
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../configure --build=x86_64-apple-darwin14.0.0 --prefix=/usr/local/Cellar/gcc/4.9.2 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2)
我创建了 gcc 到 gcc-4.9 的链接,该链接已使用 Homebrew 成功安装。我已经运行brew doctor 并且没有收到任何问题。使用code-select -install更新命令行工具
Gautams-MacBook-Pro:~ gautamrege$ ls -l /usr/local/bin/gcc
lrwxrwxr-x 1 gautamrege admin 22 Nov 14 20:14 /usr/local/bin/gcc@ -> /usr/local/bin/gcc-4.9
Gautams-MacBook-Pro:~ gautamrege$ ls -l /usr/local/bin/gcc-4.9
lrwxrwxr-x 1 gautamrege admin 31 Nov 14 20:14 /usr/local/bin/gcc-4.9@ -> ../Cellar/gcc/4.9.2/bin/gcc-4.9
这些是我的CC和clang版本(基本一样)
Gautams-MacBook-Pro:~ gautamrege$ CC -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
Gautams-MacBook-Pro:~ gautamrege$ clang -c
clang: error: no input files
Gautams-MacBook-Pro:~ gautamrege$ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
最后,这里是使用gcc -v的详细日志。
$ gcc -v a.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../configure --build=x86_64-apple-darwin14.0.0 --prefix=/usr/local/Cellar/gcc/4.9.2 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.0' '-v' '-mtune=core2'
/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/cc1 -quiet -v -D__DYNAMIC__ a.c -fPIC -quiet -dumpbase a.c -mmacosx-version-min=10.10.0 -mtune=core2 -auxbase a -version -o /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//ccvx7Ydq.s
GNU C (Homebrew gcc 4.9.2) version 4.9.2 (x86_64-apple-darwin14.0.0)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/Cellar/gcc/4.9.2/include"
ignoring nonexistent directory "/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../../../x86_64-apple-darwin14.0.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include
/usr/local/include
/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include-fixed
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
GNU C (Homebrew gcc 4.9.2) version 4.9.2 (x86_64-apple-darwin14.0.0)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f90e36a64a568856fa161772b1b4076f
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.0' '-v' '-mtune=core2'
as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//cckdbo1t.o /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//ccvx7Ydq.s
COMPILER_PATH=/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/:/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/
LIBRARY_PATH=/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.0' '-v' '-mtune=core2'
/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/collect2 -dynamic -arch x86_64 -macosx_version_min 10.10.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2 -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../.. /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//cckdbo1t.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 4.9.2
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.10.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2 -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../.. /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//cckdbo1t.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld PROJECT:ld64-136
configured to support archs: armv6 armv7 armv7s i386 x86_64
Library search paths:
/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2
/usr/local/Cellar/gcc/4.9.2/lib
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
我很确定我犯了一些基本错误。今天,所有其他软件包安装都因同样的错误而失败。有什么想法吗?
【问题讨论】:
-
您的 xcode 是否已完全安装并保持最新状态?
-
@OmnipotentEntity 不——我只更新了 Xcode 命令行工具。
brew doctor确实抱怨更新 Xcode 并且我有 Xcode 4.6.2,因为我从来不需要它。我假设你会要求我更新它,所以我会这样做并在此处更新帖子:) -
请至少使用
xcode-select -s /Library/Developer/CommandLineTools/,以便例如clang调用 XCode 6 clang。 -
@TimSmith 你成功了。唯一的变化是这个特定的命令需要作为 sudo。我会等你回答这个问题,所以你会得到荣誉。否则,我会回答。
标签: gcc homebrew osx-yosemite