如何在code :: blocks中链接gtk 3静态库? [英] How to link gtk 3 static libraries in code::blocks?

查看:259
本文介绍了如何在code :: blocks中链接gtk 3静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在代码块中测试gtk,我从以下网址下载了这些库: Static GTK + 3 for Windows | Tarnyko.net,认真的一面 [ ^ ]



i添加了mingw和gtk所有libs路径的所有包含路径,我在项目选项中添加了所有gtk静态库。



但我仍然得到找不到-lgtk-3 -lgobject-2.0 -lglib-2.0



Code :: Blocks Screen Shot 中的问题[ ^ ]



我该如何解决?



我尝试了什么:



我试图从链接库标签中删除它们,但后来我得到一些函数的未定义引用,如gtk_init等...

Hi, I'm just testing gtk in codeblocks, i downloaded the libraries from: Static GTK+3 for Windows | Tarnyko.net, serious side[^]

i added all the includes paths for mingw and gtk all the libs paths and i added all gtk static libs in the project options.

but i still get cannot find -lgtk-3 -lgobject-2.0 -lglib-2.0

Problem in Code::blocks Screen Shot[^]

how do i fix that?

What I have tried:

I have tried to remove them from the linked libraries tab, but then I get undefined references to some functions like gtk_init etc...

推荐答案

这些链接器消息告诉你链接器不知道那些库文件在哪里存储。您需要添加一些带有库目录名称的选项,以便它们可以找到它们。我不知道该选项可能是什么,因为我从未使用过code :: blocks,但我希望文档能够解释它。
Those are linker messages telling you that the linker does not know where those library files are stored. You need to add some option with the name of the library directory so it can find them. I don't know what that option might be as I have never used code::blocks, but I would expect the documentation to explain it.


你必须告诉链接器在哪里搜索对于图书馆。这可以通过将路径添加到环境变量 LIBRARY_PATH 或使用 -L< dir>在命令行上传递它们来完成。 ; 选项。到目前为止我还没有使用过CodeBlocks,但是应该有一个选项(全局或项目特定的)。



我也不知道CodeBlocks如何处理静态库的链接。链接器选项 -Wl,-Bstatic 启用所有库的静态链接。如果只应将特定库静态链接,则必须使用 -l:< libname.ext> 传递它们。请注意,必须传递带扩展名的全名(例如 -l:libgtk-3.a 而不是 -lgtk-3 对于Linux;对于Windows,它可能是 .lib 扩展名。



在任何情况下,都应检查完整的链接器命令行,以及文件是否存在于链接器搜索库的目录中。
You have to tell the linker where to search for libraries. This can be either done by adding the path(es) to the environment variable LIBRARY_PATH or by passing them on the command line using the -L<dir> option. I have not used CodeBlocks so far but there should be an option for those pathes (globally or project specific).

I also don't know how CodeBlocks handles linking of static libraries. There is the linker option -Wl,-Bstatic which enables static linking of all libraries. If only specific libraries should be statically linked, they must be passed with -l:<libname.ext>. Note that the fullname with extension must be passed (e.g. -l:libgtk-3.a instead of -lgtk-3 for Linux; for Windows it is probably the .lib extension).

In any case you should check the full linker command line and if the files exist in a directory that the linker searches for libraries.


这篇关于如何在code :: blocks中链接gtk 3静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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