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

简介: 在使用CLion做LeetCode题编译时,突然出现了一下的情况:Undefined symbols for architecture x86_64: "Solution::isCommonPrefix(std:...

在使用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.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

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

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

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

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

目录
相关文章
undefined reference to symbol 'dlsym@@GLIBC_2.17' libdl.so: error adding symbols: DSO missing from c
undefined reference to symbol 'dlsym@@GLIBC_2.17' libdl.so: error adding symbols: DSO missing from c
491 0
|
4月前
|
Swift
use_frameworks引起的Undefined symbols for architecture arm64
use_frameworks引起的Undefined symbols for architecture arm64
43 0
|
4月前
|
iOS开发
部分库不支持32位系统archive报错:Undefined symbols for architecture armv7
部分库不支持32位系统archive报错:Undefined symbols for architecture armv7
34 0
|
4月前
|
Swift
swift相关项目包含私有库引起的Undefined symbols for architecture arm64
swift相关项目包含私有库引起的Undefined symbols for architecture arm64
39 0
|
4月前
|
开发工具 iOS开发 Perl
mac电脑升级到10.15.7含有支付宝SDK的组件更新报错:AlipaySDK.framework/AlipaySDK for architecture arm64
mac电脑升级到10.15.7含有支付宝SDK的组件更新报错:AlipaySDK.framework/AlipaySDK for architecture arm64
58 0
|
开发工具 iOS开发 Perl
iOS开发 - undefined symbols for architecture x86_64,大多数都是缺少静态库,缺少静态库分下面几种
iOS开发 - undefined symbols for architecture x86_64,大多数都是缺少静态库,缺少静态库分下面几种
171 0
iOS开发 - undefined symbols for architecture x86_64,大多数都是缺少静态库,缺少静态库分下面几种
MAC编译lame ld: symbol(s) not found for architecture x86_64/_lame_init_old“, referenced from
MAC编译lame ld: symbol(s) not found for architecture x86_64/_lame_init_old“, referenced from
227 0
MAC编译出错:Undefined symbols for architecture x86_64: “_CFRelease“, referenced from:
MAC编译出错:Undefined symbols for architecture x86_64: “_CFRelease“, referenced from:
198 0
|
22天前
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
26天前
|
定位技术 Apache
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
Echarts——Invalid geoJson format Cannot read property 'length' of undefined
27 0