64“开始”

我如何链接我的程序?

我有一个2012年中期的MacBook Pro,我最近升级到OSX 10.11(埃尔卡皮坦)。 为了编译c ++程序,我必须重新安装我使用brew创建的g ++。

现在,当我尝试链接我的程序时出现错误。

g ++ - 6 -o hello hello.o

体系结构x86_64的未定义符号:“start”,引用来自:隐式条目/ start for main可执行文件ld:找不到架构x86_64的符号collect2:错误:ld返回1退出状态

这是我的代码:hello.cpp

#include <iostream>
int main(){
    std::cout<<"Beginning program";
    return 0;
}

这是我用-v标志链接时的输出

g ++ - 6 -o hello hello.o -v

使用内置规格。

COLLECT_GCC =克++ - 6

COLLECT_LTO_WRAPPER =的/ usr /本地/地窖/ GCC / 6.2.0 /的libexec / GCC / x86_64的-苹果darwin15.6.0 / 6.2.0 / LTO-包装

目标:x86_64-apple-darwin15.6.0

配置:../configure --build = x86_64-apple-darwin15.6.0 --prefix = / usr / local / Cellar / gcc / 6.2.0 --libdir = / usr / local / Cellar / gcc / 6.2.0 / lib / gcc / 6 --enable-languages = c,c ++,objc,obj-c ++,fortran --program-suffix = -6 --with-gmp = / usr / local / opt / gmp --with-mpfr = / usr / local / opt / mpfr --with-mpc = / usr / local / opt / libmpc --with-isl = / usr / local / opt / isl --with-system-zlib --enable-libstdcxx- time = yes --enable-stage1-checking --enable-checking = release --enable -lto --with-build-config = bootstrap-debug --disable-werror --with-pkgversion ='Homebrew gcc 6.2.0 '--with-bugurl = https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib

线程模型:posix

gcc版本6.2.0(Homebrew gcc 6.2.0)

COMPILER_PATH =的/ usr /本地/地窖/ GCC / 6.2.0 /的libexec / GCC / x86_64的-苹果darwin15.6.0 / 6.2.0 /:在/ usr /本地/地窖/ GCC / 6.2.0 /的libexec / GCC / x86_64的 - 苹果 - darwin15.6.0 / 6.2.0 /:在/ usr /本地/库/ GCC / 6.2.0 / libexec目录/ GCC / x86_64的 - 苹果darwin15.6.0 /:在/ usr /本地/库/ GCC / 6.2.0 /lib/gcc/6/gcc/x86_64-apple-darwin15.6.0/6.2.0/:/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin15.6.0 /

LIBRARY_PATH =的/ usr /本地/地窖/ GCC / 6.2.0 / LIB / GCC / 6 / GCC / x86_64的-苹果darwin15.6.0 / 6.2.0 /:在/ usr /本地/地窖/ GCC / 6.2.0 / lib中/gcc/6/gcc/x86_64-apple-darwin15.6.0/6.2.0/../../../

COLLECT_GCC_OPTIONS =' - o''hello'-v''-mmacosx-version-min = 10.11.3''-shared-libgcc''-mtune = core2'/usr/local/Cellar/gcc/6.2.0/ libexec / gcc / x86_64 -app -darwin15.6.0 / 6.2.0 / collect2 -dynamic -arch x86_64 -macosx_version_min 10.11.3 -weak_reference_mismatches非弱-o hello -L / usr / local / Cellar / gcc / 6.2.0 / / usr / local / Cellar / gcc / 6.2.0 / lib / gcc / 6 / gcc / x86_64-apple-darwin15.6.0 / 6.2.0 /../../ hello.o -lstdc ++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v collect2版本6.2.0 / usr / bin / ld -dynamic -arch x86_64 -macosx_version_min 10.11 .3 -weak_reference_mismatches非弱-o hello -L / usr / local / Cellar / gcc / 6.2.0 / lib / gcc / 6 / gcc / x86_64 -app -darwin15.6.0 / 6.2.0 -L / usr / local /Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin15.6.0/6.2.0/../../ .. hello.o -lstdc ++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v @(#)PROGRAM:ld PROJECT:ld64-136配置为支持archs:armv6 armv7 armv7s i386 x86_64

库搜索路径:/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin15.6.0/6.2.0 /usr/local/Cellar/gcc/6.2.0/lib / gcc / 6 / usr / lib / usr / local / lib

框架搜索路径:/库/框架/ /系统/库/框架/

体系结构x86_64的未定义符号:“start”,引用来自:隐式条目/ start for main可执行文件ld:找不到架构x86_64的符号collect2:错误:ld返回1退出状态

我从其他帖子读到,这可能是由旧版g ++编译的默认库的问题。 但我认为这不是问题,因为库搜索路径似乎指向g ++ - 6的库。

链接地址: http://www.djcxy.com/p/75477.html

上一篇: 64"start"

下一篇: Why is there a /usr/local/opt directory created by Homebrew and should I use it?