Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 未定义的符号:";基本“U文件”;在我的Mac OS上使用gcc_C++_Macos_Gcc_Undefined Reference - Fatal编程技术网

C++ 未定义的符号:";基本“U文件”;在我的Mac OS上使用gcc

C++ 未定义的符号:";基本“U文件”;在我的Mac OS上使用gcc,c++,macos,gcc,undefined-reference,C++,Macos,Gcc,Undefined Reference,我正在尝试编译一个第三方工具。命令行看起来像 gcc <many .o files and .a files> -g -lgmp -lgmpxx -lstdc++ -o bintool 但我不知道它实际上是在哪里实现的,以及如何正确地与之链接。我应该从哪里着手解决这个问题?我使用Mac OS。我的“gcc--version”给出了: Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-

我正在尝试编译一个第三方工具。命令行看起来像

gcc <many .o files and .a files>  -g -lgmp -lgmpxx -lstdc++  -o bintool
但我不知道它实际上是在哪里实现的,以及如何正确地与之链接。我应该从哪里着手解决这个问题?我使用Mac OS。我的“gcc--version”给出了:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix

有没有关于如何修复“未定义符号”错误的想法?谢谢

试着用g++编译并去掉
-lstdc++
。你可能想尝试
g++-g-o bintool-lgmp-lgmpxx
,在
.o
文件后面列出libs。@JoachimIsaksson你指的是哪个libs?你是指GMP吗?当使用C++时,你应该真正养成使用C++前端程序的习惯,即:代码> G++< /COD>或<代码> CLAN++<代码>。当编译到对象文件时,这真的不重要,但是当链接时才重要。是的。。。除非应用程序需要特殊链接,“默认情况下”,将
-l
选项放在最后通常是个好主意。
/usr/include/c++/4.2.1/bits/basic_file.h
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix