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