Undefined symbols for architecture x86_64: in mac OS

博客内容讲述了在macOS Mojave上,使用Xcode 11.3.1进行项目编译时遇到链接错误,原因是缺少pcre2库的相关函数实现。解决方法是引入pcre2的静态库,具体操作为找到/opt/local/lib下的对应库文件并添加到开发环境中,从而成功解决链接错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、我当前使用的mac OS系统版本:

  macOS Mojave

Version 10.14.6

2、Command Line Tools:

Xcode Version 11.3.1 (11C504)

3、问题如下:

Showing All Errors Only

Ld /Users/***/Library/Developer/Xcode/DerivedData/UseQueue-dcwulpumiqqtwjgycwqbsluancwo/Build/Products/Debug/UseQueue normal x86_64 (in target 'UseNet' from project 'UseNet')

Undefined symbols for architecture x86_64:

  "_pcre2_code_free_8", referenced from:

      _ngx_regex_cleanup in ngx_regex.o

  "_pcre2_compile_8", referenced from:

      _ngx_regex_compile in ngx_regex.o

  "_pcre2_compile_context_create_8", referenced from:

      _ngx_regex_compile in ngx_regex.o

  "_pcre2_compile_context_free_8", referenced from:

      _ngx_regex_cleanup in ngx_regex.o

  "_pcre2_config_8", referenced from:

      _ngx_regex_pcre_jit in ngx_regex.o

  "_pcre2_general_context_create_8", referenced from:

      _ngx_regex_compile in ngx_regex.o

  "_pcre2_general_context_free_8", referenced from:

      _ngx_regex_compile in ngx_regex.o

  "_pcre2_get_error_message_8", referenced from:

      _ngx_regex_compile in ngx_regex.o

  "_pcre2_get_ovector_count_8", referenced from:

      _ngx_regex_exec in ngx_regex.o

  "_pcre2_get_ovector_pointer_8", referenced from:

      _ngx_regex_exec in ngx_regex.o

  "_pcre2_jit_compile_8", referenced from:

      _ngx_regex_module_init in ngx_regex.o

  "_pcre2_match_8", referenced from:

      _ngx_regex_exec in ngx_regex.o

  "_pcre2_match_data_create_8", referenced from:

      _ngx_regex_exec in ngx_regex.o

  "_pcre2_match_data_free_8", referenced from:

      _ngx_regex_exec in ngx_regex.o

      _ngx_regex_cleanup in ngx_regex.o

  "_pcre2_pattern_info_8", referenced from:

      _ngx_regex_compile in ngx_regex.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

其实,不管在什么系统环境下,针对此问题的解决是类似的。从报的错误来看,很明显,是在当前的开发程序中无法访问到对应函数的实现,也就是说有函数声明,却找不到函数体。明白了原因,解决就简单了。

解决方式

        直接引入pcre2相应版本的静态库。

        为什么需要引入呢?原因,程序编译连接时,在默认搜索目录下没有找到对应的函数实现(相应的库)。此依赖软件,是我个人使用port自行安装的,没有在系统lib下。

        找到/opt/local/lib,将对应的库拖拽添加到开发环境中,如图,

 问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值