LD:找不到建筑符号
ld: symbol(s) not found for architecture
首先,我想说我意识到这个问题已经被问了十几次,而且我读了无数的解决方案,没有任何运气,所以我再问一次。
我正在使用OS X Mavericks 10.9.5,用Sublime 3编写并使用g++终端进行编译
我正在尝试编译这个简单的文件(测试.cpp)
#include <iostream>
#include <SDL2/SDL.h>
int main () {
if(SDL_Init(SDL_INIT_VIDEO)) {
std::cout << "I made it this far" << std::endl;
}
return 0;
}
编译器行:
g++ test.cpp
这将返回错误:
Undefined symbols for architecture x86_64:
"_SDL_Init", referenced from:
_main in test-ebbae4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
因此,我尝试添加许多不同的标志,-m32
只会更改结果以抛出Undefined symbols for architecture i386:
并ld: symbol(s) not found for architecture i386
我已经尝试了不同的-arch
变体,但我似乎无法让它工作。 也玩过-l -I
标志,但我不确定我知道他们做什么/他们如何提供帮助。
有没有人知道下一步该怎么做?
编辑:一些附加信息。我尝试使用 SDL2 的 .framework,这并没有改变任何东西,目前我使用的是通过编译源代码安装的 SDL2。位于usr/local/SDL2
的标头
G++ 测试.cpp
您还应该指定 SDL 库:
G++ test.cpp -LSDL2
如果编译器驱动程序不知道路径,则可能需要包含路径:
g++ test.cpp -L/path/to/the/library -lsdl2
相关文章:
- 建筑x86_64的未定义符号:"vtkDebugLeaksManager::vtkDebugLeaksManager()",引用自:
- Qt Creator项目打破:"找不到建筑x86_64符号"
- C++ 建筑x86_64的未定义符号(类似)
- 建筑x86_64的未定义符号 (curlpp)
- 建筑x86_64的未定义符号 ->建筑x86_64找不到的符号
- 建筑x86_64的未定义符号 - 如何查找丢失的文件
- 凉亭ROS插件出错:建筑x86_64的未定义符号
- 未定义的建筑符号,尝试了i386和其他符号
- 加速C++:建筑x86_64的未定义符号
- 建筑x86_64的未定义符号:链接错误
- 建筑x86_64的未定义符号:"_SSLv2_ ..."
- 叮当 Mac 链接错误与 gtest 建筑x86_64的未定义符号
- 另一个:建筑x86_64:的未定义符号
- C++ 制作链接步骤:建筑x86_64的未定义符号
- 石英:为x86_64建筑构建时未定义的符号
- 建筑x86_64的未定义符号:C++编译
- LD:找不到建筑符号
- 建筑x86_64的未定义符号:"Shape::get_area()",引用自:Shape.o 中的形状可投票。
- 未定义的符号 建筑x86_64的未定义符号:"_kCFAllocatorDefault"
- 建筑x86_64的未定义符号。我的代码有什么问题?