- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我收到一个 ld: symbol(s) not found for architecture x86_64
错误。我确实通过以前的线程进行了彻底的搜索,但没有找到解决方案。
作为测试,我正在编译程序 test.cpp:
#include <iostream>
using namespace std;
int main(){
return 0;
}
使用 Makefile:
CXX=g++
CXXFLAGS=-g -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings $(shell root-config --cflags --glibs)
CPPFLAGS+=-MMD -MP
LDFLAGS=-g $(shell root-config --ldflags)
LDLIBS=$(shell root-config --libs)
test.o: test.cpp
test: test.o
-include test.d
在我的 linux 计算机上运行 make test
会产生以下正确输出:
CAM ~/Wenu $ make test
g++ -g -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings -pthread -m64 -I/cvmfs/lhcb.cern.ch/lib/RootConfig/pro/x86_64-slc5-gcc46-opt/root/include -L/cvmfs/lhcb.cern.ch/lib/RootConfig/pro/x86_64-slc5-gcc46-opt/root/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -MMD -MP -c -o test.o test.cpp
cc -g -m64 test.o -L/cvmfs/lhcb.cern.ch/lib/RootConfig/pro/x86_64-slc5-gcc46-opt/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -o test
CAM ~/Wenu $
在我的 Mac 上编译它在链接阶段失败,出现 ld: symbol(s) not found for architecture x86_64
错误:
MAC ~/Transmit/Wenu $ make test
g++ -g -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings -pthread -m64 -I/opt/local/root-v5-34-00/include -L/opt/local/root-v5-34-00/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -Wl,-rpath,/opt/local/root-v5-34-00/lib -lm -ldl -MMD -MP -c -o test.o test.cpp
i686-apple-darwin11-llvm-g++-4.2: -lGui: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lCore: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lCint: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lRIO: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lNet: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lHist: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lGraf: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lGraf3d: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lGpad: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lTree: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lRint: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lPostscript: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lMatrix: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lPhysics: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lMathCore: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lThread: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lpthread: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -rpath: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: /opt/local/root-v5-34-00/lib: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -lm: linker input file unused because linking not done
i686-apple-darwin11-llvm-g++-4.2: -ldl: linker input file unused because linking not done
cc -g -m64 test.o -L/opt/local/root-v5-34-00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -Wl,-rpath,/opt/local/root-v5-34-00/lib -lm -ldl -o test
Undefined symbols for architecture x86_64:
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in test.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1
如有任何帮助,我们将不胜感激。
以防万一与此相关,我有一台装有 OS X 10.7.5 的 64 位 Mac,并且我有一个带有 XCode 命令行工具的编译器:
MAC ~/Transmit/Wenu $ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
ROOT 是我在程序中使用的 C++ 库的集合。
最佳答案
Running make test in my linux computer produces the following correct output
这只是偶然的:你正在链接一个 C++
用 cc
编程.如果您使用更多 C++
,它将停止在 Linux 上工作,例如试着把 cout << "Hello" << endl;
进入你的main
.
Also my file has a cpp extension so I don't understand why cc is used.
因为默认的 make 规则会产生 test
来自 test.o
使用 $CC
,而不是 $CXX
.
您可以通过以下几种方式之一解决此问题:
$CC
也是g++
, 或Makefile
在制作 test
时使用非默认规则来自 test.o
, 或test
取决于 test.cpp
(如果您这样做,make
将使用正确的默认规则)。关于c++ - ld : symbol(s) not found for architecture x86_64 using GNU Make and clang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14115337/
我有数百个文件,命名如下: RG1-t.txt RG1-n.txt RG2-t.txt RG2-n.txt 等等... 我想使用GNU并行在它们上运行脚本,但是我很难获得文件的基本名称,因此RG1,R
从例子 seq 1 100 | parallel -I @@ \ > 'mkdir top-@@;seq 1 100 | parallel -X mkdir top-@@/sub-{} 怎么办-X ,
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我有一个简单的 Makefile: VAR := aaa include a.inc VAR += bbb 和a.inc some_target: $(VAR) @echo "refe
按照指南制作新类(class)。我可以使用 gst 命令制作新的或加载图像文件 (.im)。我输入代码来创建一个 Account 类,然后可以创建一个新类。 问题如何在关闭 gst 窗口之前将类保存到
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 10年前关闭。 Improve this
我想使用 GNU screen 来监视这样的串行 USB 端口: $ screen /dev/ttyUSB0 115200 但我需要调整一些终端线路设置。我已经进行了几次尝试,但似乎都没有奏效。例如,
我已阅读全文 documentation对于 gnu 排序和在线搜索,但我找不到 --buffer-size 选项的默认值是什么(它决定了程序在运行时使用多少系统内存)。我猜它是根据系统总内存以某种方
我正在使用 parallel --keep-order --line-buffer --halt 2 在一堆命令上并行调用 GNU .每隔一段时间,其中一个命令就会失败,并且 GNU 并行打印: p
这个问题与问题 2543127 的精神相似。 . 我有一个带有头文件列表的 gnu makefile。每个头文件可能位于不同的目录中,例如, HEADERS = $(wildcard *.h) $(w
假设我有以下 GNU make 目标: create_dir: @mkdir objects build_asm: $(ASM_FILES) @echo
默认情况下,当您在 GNU Screen 中创建新窗口时,它将在调用 Screen 的目录中启动。我想在当前所在窗口的当前工作目录的 GNU Screen 中启动一个新窗口。我该怎么做? 最佳答案 查
我想在几个输入上运行几个长时间运行的进程。例如。: solver_a problem_1 solver_b problem_1 ... solver_b problem_18 solver_c pro
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 8年前关闭
我可以看到在多个输入上运行并行作业是多么容易,但是有没有其他方法可以通过将命令放入文件并重复多次来并行运行同一作业多次? parallel -j+0 ::: './dosomejob.sh' 但是告诉
所以我一直在尝试寻找一些关于 GNU screen 实际上如何在 high 下工作的信息,而不必真正阅读源代码,但我一直无法这样做。 screen 做了什么,即使在终端 session 关闭时它也能保
在调查崩溃时,我遇到了以下代码片段并立即意识到 mov 指令实际上应该是 movq 以获得正确的 64 位寄存器操作。 #elif defined(__x86_64__) unsigned l
我安装了 indent使用 brew感谢命令 brew install gnu-indent所以现在我有 gnu-indent-2.2.10到目前为止安装在我的 MacOS X 上,非常好。我的问题是
考虑这个Makefile: .PHONY: all all: main.txt main.txt: build/main.txt cp build/main.txt . %/main.txt:
假设目录输入中有 1000 个扩展名为 .xhtml 的文件,并且这些文件的某个子集(输出路径在 $(FILES) 中)需要通过 xslt 转换为目录输出中具有相同名称的文件.一个简单的 make 规
我是一名优秀的程序员,十分优秀!