为什么明明存在/usr/lib/libfastcommon.so 文件, gcc -L/usr/lib -lfastcommon 确报错??

2015-11-27 22:09:56 +08:00
 marginleft

运行下面的命令;

$ ll /usr/lib/libfastcommon.so
-rwxr-xr-x  1 root  wheel  250604 11 27 21:35 /usr/lib/libfastcommon.so*
$ ll /usr/lib64/libfastcommon.so
-rwxr-xr-x  1 root  wheel  250604 11 27 21:35 /usr/lib64/libfastcommon.so*
$ gcc -L/usr/lib64 -lfastcommon
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ gcc -L/usr/lib -lfastcommon
ld: library not found for -lfastcommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)

问题是,为什么明明存在 /usr/lib/libfastcommon.so 文件, gcc -L/usr/lib -lfastcommon 确报错??

环境:

$ uname -a
Darwin gfdeMacBook-Air.local 15.0.0 Darwin Kernel Version 15.0.0: Wed Aug 26 16:57:32 PDT 2015; root:xnu-3247.1.106~1/RELEASE_X86_64 x86_64

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
4694 次点击
所在节点    问与答
5 条回复
zts1993
2015-11-27 23:37:32 +08:00
so 是 32 位,, gcc 64 位默认找 64 位。。我也不太懂。。
proudzhu
2015-11-28 08:22:37 +08:00
因为 /usr/lib 是个软链接?不是提示用 -v 查看错误的吗?
nareix
2015-11-28 09:25:56 +08:00
能 diff 下 /usr/lib/libfastcommon.so /usr/lib64/libfastcommon.so
kiwi95
2015-11-28 12:34:06 +08:00
.so 在 /lib64 下做一个软连接试试,之前遇到过类似的问题
palfortime
2015-11-28 12:42:22 +08:00
gcc -L/usr/lib64 -lfastcommon
这行命令的输出说了没有 main 入口, gcc 是要编出一个可执行的文件。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/239525

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX