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,将对应的库拖拽添加到开发环境中,如图,
问题解决。