GCC / LD无法找到链接库 [英] GCC/LD cannot find link library

查看:267
本文介绍了GCC / LD无法找到链接库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

操作系统:Windows 7企业版x64
IDE:Eclipse Juno / CDT
编译器:MinGW 4.6.2(C:\MinGW)



​​ user697111 ,我无法让ld.exe找到外部库。



简单的程序编译和链接很好,但是当我尝试使用提供的库添加SQL funcionality时,我在Eclipse中收到此错误消息:c:/ mingw / bin /。 ./lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe:找不到-lC:\MinGW\lib\libodbc32.a。

我将C:\ MinGW \ lib指定为项目库路径。我将C:\MinGW\lib\libodbc32.a指定为唯一的Project Library(这会导致IDE中的未解析的引用错误消失)。



我切换到CLI并粘贴编译命令。对于库名称,我试过:
odbc32,odbc32.a,libodbc32,libcodbc32.a
我也试过:
odbccp32,odbccp32.a,libodbccp32,libodbccp32.a
我使用了正斜杠,反斜杠,双反斜线,路径引号,整个-l参数(这是Eclipse对-L参数的操作)。

我将库复制到包含编译代码的目录中,以消除指定路径的需要。我将它们复制到包含ld.exe的目录中。我更新了Windows路径以包含目录并重新启动了Eclipse和CLI。



如果我完全删除-l参数,则会出现各种未解决的引用错误。看起来ld.exe 找到库,但一心想隐藏真正的问题。



链接到内置函数的秘诀是什么?在SQL库中吗?

解决方案

使用CLI时,不要在-l参数中包含路径,请删除.a后缀和lib前缀:
-lodbc32
路径由 -L 参数提供。



为了使它在Eclipse中工作,编辑库条目(项目属性/路径和符号/库选项卡)添加后。删除路径,lib和.a。 (Eclipse会警告使用相对路径的危险。)每当添加一个外部库时,请记住这一步。



现在它在Eclipse和CLI中都可以正常工作。 / p>

OS: Windows 7 Enterprise x64 IDE: Eclipse Juno/CDT Compiler: MinGW 4.6.2 (C:\MinGW)

Like user697111, I cannot get ld.exe to find an external library.

Simple programs compile and link fine, but when I try to add SQL funcionality with the supplied library, I get this error message in Eclipse: "c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lC:\MinGW\lib\libodbc32.a".

I specified C:\MinGW\lib as the Project Library Path. I specified C:\MinGW\lib\libodbc32.a as the one-and-only Project Library (this made the unresolved-reference errors go away in the IDE).

I switched to the CLI and pasted the compile command. For the library name, I've tried: odbc32, odbc32.a, libodbc32, libcodbc32.a I also tried: odbccp32, odbccp32.a, libodbccp32, libodbccp32.a I've used forward slashes, backslashes, double-backslashes, quotes around the path, quotes around the entire -l parameter (which is what Eclipse does to the -L parameter).

I copied the libraries into the directory containing the compiled code to eliminate the need to specify the path. I copied them into the directory containing ld.exe. I updated the Windows path to include the directory and restarted Eclipse and the CLI.

If I remove the -l parameter entirely, I get all kinds of unresolved-reference errors. It seems ld.exe is finding the library but is bent on hiding the real problem.

What is the secret to linking to the built-in SQL libraries?

解决方案

Got it at last!

When using the CLI, don't include the path in the -l parameter, drop the ".a" suffix and the "lib" prefix: -lodbc32 The path is supplied by the -L parameter.

To make it work in Eclipse, edit the Library entry (Project Properties/Paths and Symbols/Libraries tab) after adding it. Remove the path, "lib", and ".a". (Eclipse will warn about the dangers of using relative paths.) Remember this step whenever you add an external library.

It now works fine in both Eclipse and the CLI.

这篇关于GCC / LD无法找到链接库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆