Nginx 安装 (mac os) 错误 ld: symbol(s) not found for architecture x86_64
今天在mac os 上编译安装Nginx时候,报错:ld: symbol(s) not found for architecture x86_64, 经过一番折腾之后发现,由于Nginx依赖openssl库,查看openssl的./config 文件发现,这个问题应该是 openssl/config脚本猜对你的系统是64位,但是 会根据$KERNEL_BITS来判断是否开启x86_64编译,默认不开启,他会给你5秒时间确认是否停止编译,手动设置x86_64编译,所以默认你生成的openssl库文件是32位的,最后静态链接到nginx会出错。目前看来没有很好的方法把x86_64的参数传到openssl配置文件中 (openssl/config 猜测os架构,设置编译的参数是32位还是64位,默认是32位,然后调用openssl/Configure生成Makefile),
解决办法就是:
先运行nginx源码目录下运行
$ ./configure
然后在objs里,打开Makefile,
找到: ./config --prefix=xxx.openssl no-shared (注释:XXX是已存在的openssl源码路径)
把该段的 ./config 改成 ./Configure darwin64-x86_64-cc 其他后面参数不变,保存
然后再make就编译通过了
--------------------------------------------------------------------------
pkg-config 安装 (mac os) 错误 ld: symbol(s) not found for architecture x86_64
Making all in .
CCLD pkg-config
Undefined symbols for architecture x86_64:
"_CFRelease", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFStringGetCString", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFStringGetCStringPtr", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFStringGetLength", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFURLCopyFileSystemPath", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFURLCreateFromFSRef", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_FSFindFolder", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_kCFAllocatorSystemDefault", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [pkg-config] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
用最新的pkg-config-0.29.2.tar.gz,支持macos。可以正常make
总结:之前用0.29版,估计是没有兼容macOs的芯片系统,0.29.2做了升级