marginleft
V2EX  ›  问与答

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

  •  
  •   marginleft · Nov 27, 2015 · 5599 views
    This topic created in 3852 days ago, the information mentioned may be changed or developed.

    运行下面的命令;

    $ 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 replies    2015-11-28 12:42:22 +08:00
    zts1993
        1
    zts1993  
       Nov 27, 2015
    so 是 32 位,, gcc 64 位默认找 64 位。。我也不太懂。。
    proudzhu
        2
    proudzhu  
       Nov 28, 2015 via Android
    因为 /usr/lib 是个软链接?不是提示用 -v 查看错误的吗?
    nareix
        3
    nareix  
       Nov 28, 2015
    能 diff 下 /usr/lib/libfastcommon.so /usr/lib64/libfastcommon.so
    kiwi95
        4
    kiwi95  
       Nov 28, 2015
    .so 在 /lib64 下做一个软连接试试,之前遇到过类似的问题
    palfortime
        5
    palfortime  
       Nov 28, 2015 via Android
    gcc -L/usr/lib64 -lfastcommon
    这行命令的输出说了没有 main 入口, gcc 是要编出一个可执行的文件。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   958 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 18:33 · PVG 02:33 · LAX 11:33 · JFK 14:33
    ♥ Do have faith in what you're doing.