Mac下Clion编译错误:Undefined symbols for architecture x86_64

来源:互联网 发布:mysql月租 编辑:程序博客网 时间:2024/05/17 20:13

在使用CLion做LeetCode题编译时,突然出现了一下的情况:

Undefined symbols for architecture x86_64:  "Solution::isCommonPrefix(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, int)", referenced from:      Solution::longestCommonPrefix(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) in main.cpp.old: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)

首先在网上查询错误原因,大概有两点:
1、编译lib没有找到,可能相应的编译环境不正确,缺少某样东西。
2、自己写的代码问题,最有可能的原因就是所用的控制符与系统符号相冲突或者其他情况。

在网上查了一大堆修改编译选项的都没有什么用
最后无奈仔细检查了一下程序,好吧,发现问题了

有一个函数定义和声明没有严格对应,于是导致编译器在编译的时候产生的符号表无法与实际程序中的函数对应,所以导致了该错误。

所以总结如下:不管怎么说先排查自己的程序到底有没有问题,没有问题在考虑其他!

阅读全文
0 0
原创粉丝点击