V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
marginleft
V2EX  ›  问与答

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

  •  
  •   marginleft · 2015-11-27 22:09:56 +08:00 · 4660 次点击
    这是一个创建于 3044 天前的主题,其中的信息可能已经有所发展或是发生改变。

    运行下面的命令;

    $ 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
    
    5 条回复    2015-11-28 12:42:22 +08:00
    zts1993
        1
    zts1993  
       2015-11-27 23:37:32 +08:00
    so 是 32 位,, gcc 64 位默认找 64 位。。我也不太懂。。
    proudzhu
        2
    proudzhu  
       2015-11-28 08:22:37 +08:00 via Android
    因为 /usr/lib 是个软链接?不是提示用 -v 查看错误的吗?
    nareix
        3
    nareix  
       2015-11-28 09:25:56 +08:00
    能 diff 下 /usr/lib/libfastcommon.so /usr/lib64/libfastcommon.so
    kiwi95
        4
    kiwi95  
       2015-11-28 12:34:06 +08:00
    .so 在 /lib64 下做一个软连接试试,之前遇到过类似的问题
    palfortime
        5
    palfortime  
       2015-11-28 12:42:22 +08:00 via Android
    gcc -L/usr/lib64 -lfastcommon
    这行命令的输出说了没有 main 入口, gcc 是要编出一个可执行的文件。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5224 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 01:24 · PVG 09:24 · LAX 18:24 · JFK 21:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.