GCC,链接库,没有发现? [英] GCC, linking libraries, not found?

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

问题描述


  • 操作系统:Windows 7专业版X64

  • IDE:Eclipse IDE中的C / C ++开发者

  • 编译器:MinGW的(介绍最新,4.5.2)

编译HelloWorld.c工程;但是当我尝试添加它闷死了。一些外部库

Compiling HelloWorld.c works; but when I try to add some external libraries it chokes.

我添加了.A和.dll文件到我的'图书馆';两者的路径添加到PATH和库路径。我也把包含文件和配置包含。我曾经被认为的程序库,与Win / MinGW的兼容。他们也有MSVC一个不同的下载它确实工作。

I added the .a and .dll files to my 'Libraries'; add the path of both to PATH and Library Path. I also put the include files and configured the Include. The libraries I have are said to be compatible with win/mingw. They also have a different download for MSVC which does work.

沮丧。该ld.exe给出了完整路径,显然那里,我有权读取/写入它们。我还包括它们不包含路径(他们是在库路径和路径)。

Frustrating. The ld.exe gives the full path and obviously there and I have permissions to read/write them. I also included them without path (they are in library path and path).

我不明白为什么这是行不通的。

I don't understand why this isn't working.

C:/ MinGW的/ bin中/../ lib中/ GCC / mingw32的/ 4.5.2 /../../../../的mingw32 /斌/ ld.exe:找不到-lC:\\犀牛\\ DATA \\ LIB \\ glfw.dll
C:/ MinGW的/ bin中/../ lib中/ GCC / mingw32的/ 4.5.2 /../../../../的mingw32 /斌/ ld.exe:找不到-lC:\\犀牛\\ DATA \\ LIB \\ libglfwdll.a
C:/ MinGW的/ bin中/../ lib中/ GCC / mingw32的/ 4.5.2 /../../../../的mingw32 /斌/ ld.exe:找不到-lC:\\犀牛\\ DATA \\ LIB \\ libglfw.a

c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lC:\rhino\data\lib\glfw.dll c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lC:\rhino\data\lib\libglfwdll.a c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lC:\rhino\data\lib\libglfw.a

C:\Users\rhino>dir C:\rhino\data\lib\libglfw.a
04/15/2011  05:24 PM            70,384 libglfw.a

更新:

我甚至将它们添加到我的C:\\ MinGW的\\ lib目录路径,它仍然无法找到他们。

I've even added them to my C:\MinGW\lib path and it still can't find them.

推荐答案

迈克尔·伯尔指出,在命令行上引用库的正确途径。到库的路径与 -L 开关给出,并与 -l <​​/ code>开关库的名称(该库是文件名,名不开头的 LIB 部分,而 .A 后缀在结束)。

Michael Burr pointed out the correct way of referencing libraries on the command line. The path to the library is given with the -L switch, and the name of the library with the -l switch (the name of the library being the file name, without the lib part at the beginning, and the .a suffix at the end).

还有一点需要指出的是,你要链接到两个静态(libglfw.a)和库,都包含在下载动态(glfw.dll)版本,在同一时间。相反,你应该选一个,根据您的需求/欲望,只能链接到一个。

One more thing to point out is that you're trying to link to both the static (libglfw.a) and the dynamic (glfw.dll) version of the library, which are both included in the download, at the same time. Instead, you should pick one, based on your needs/desires, and only link to that one.

针对静态版本链接是直接的。只需添加 -lglfw 到命令行。

Linking against the static version is straightforward. Just add -lglfw to the command line.

要使用的动态库,你应该与导入库的DLL( libglfwdll.a )链接,使用 -lglfwdll 开关,并且省略了链接命令DLL本身。基本上,导入库中不包含任何对象code,但只能定义;实际code是在DLL中。 DLL将在运行时动态链接。 (对于这个工作,该系统具有能够找到的DLL;也就是说,它必须是在当前工作目录,在目录中的路径,或者它的目录已被添加到所使用的特殊的环境变量为这件事,但是这个要成为重要的是,您必须先建立可执行的成功)

To use the dynamic library, you should link against the import library for the dll (libglfwdll.a), by using the -lglfwdll switch, and omit the dll itself from the link command. Basically, the import library doesn't contain any object code, but only definitions; the actual code is in the dll. The dll will be dynamically linked at run time. (For this to work, the system has to be able to find the dll; i.e. it has to be in the current working directory, in a directory that is in the path, or its directory has to be added to a special environment variable used for this thing; but for this to become important, you first have to succeed in building the executable.)

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

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