代码之家  ›  专栏  ›  技术社区  ›  JagPK

Mingw和Eclipse无法找到库-2

  •  2
  • JagPK  · 技术社区  · 10 年前

    我所面临的情况与古斯塔沃在下文中提出的问题完全相同 Link 。此外,我尝试了该链接和其他标签中发布的所有解决方案(例如将库名称从opus.a更改为libopus.a,将“\”更改为“/”等),但这些都没有解决我的问题。通过打开库文件的财产,将显示以下内容:

    路径: /demo/opsfile/lipopusfile.a

    类型 :文件(静态库)

    地方 :U:\data\Jag\eclipse\wrksp\demo\opusfile\libopusfile.a

    Mingw显示的错误消息如下:

    15:56:57 **** Incremental Build of configuration Debug for project demo ****
    Info: Internal Builder is used for build
    gcc -o demo.exe "src\\demo.o" -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a 
    c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lU:/data/Jag/eclipse/wrksp/demo/opusfile/libopusfile.a
    collect2.exe: error: ld returned 1 exit status
    
    collect2.exe: error: ld returned 1 exit status
    

    有人能告诉我我错过了什么吗?我无法解决这个问题

    1 回复  |  直到 7 年前
        1
  •  1
  •   Community kavare    7 年前

    我想我找到了解决方案,这要感谢本文中的答案 Link 因此,基本上为了总结解决方案,我必须在指定库(-l参数)时删除“lib”前缀、“.a”后缀和库路径。必须在-L参数中指定库路径。这解决了上述问题,但导致了Mingw的另一个障碍:

    libopusfile.dll.a: could not read symbols: Archive has no index; run ranlib to add one.
    

    我在命令提示符下执行了“ranlib”命令

    cmd_path> ranlib libopusfile.dll.a 
    

    ,这解决了我的所有问题!