简体   繁体   English

wxWidgets:要链接哪些文件?

[英]wxWidgets: Which files to link?

I am learning C++ and, in order to do so, am writing a sample wxWidgets application. 我正在学习C ++,为了做到这一点,我正在编写一个示例wxWidgets应用程序。

However, none of the documentation I can find on the wxWidgets website tell me what library names to pass to the linker. 但是,我在wxWidgets网站上找不到的文档都没有告诉我要传递给链接器的库名。

Now, apart from wxWidgets, is there a general rule of thumb or some other convention by which I should/would know, for any library, what the names of the object files are against which I am linking? 现在,除了wxWidgets之外,是否有一般的经验法则或我应该/将要知道的其他约定,对于任何库,我链接的目标文件的名称是什么?

After a bit more Googling, I found a page on the wxWidgets wiki which relates to the Code::Blocks IDE, but which also works for me. 经过一段时间的谷歌搜索,我在wxWidgets wiki上找到了一个与Code :: Blocks IDE相关的页面,但它也适用于我。 By adding the following to the linker options, it picks up all the necessary files to link: 通过将以下内容添加到链接器选项,它将获取要链接的所有必需文件:

`wx-config --libs`

(So that does not solve my "general rule" problem; for any library I am working with, I still have to find out what files to link against, but at least this solves the problem for wxWidgets). (因此这不能解决我的“一般规则”问题;对于我正在使用的任何库,我仍然需要找出要链接的文件,但至少这解决了wxWidgets的问题)。

The build instructions are different for each platform and so you need to refer to the platform-specific files such as docs/gtk/install.txt (which mentions wx-config ) or docs/msw/install.txt to find them. 每个平台的构建说明都不同,因此您需要引用特定于平台的文件,例如docs / gtk / install.txt (提及wx-config )或docs / msw / install.txt来查找它们。

FWIW wxWidgets project would also definitely gratefully accept any patches to the main manual improving the organization of the docs. FWIW wxWidgets项目也肯定会感谢接受主要手册的任何补丁,以改进文档的组织。

We have more of a "rule of ring finger", instead of a thumb 我们有更多的“无名指规则”,而不是拇指

Generally, if you compile the library by hand, it will produce several library files (usually .a .lib or something similar, depending entirely on your compiler and your ./configure) these are produced (typically) because of a makefile's build script. 通常,如果您手动编译库,它将生成几个库文件(通常是.a .lib或类似的东西,完全取决于您的编译器和./configure),这些文件是(通常)生成的,因为makefile的构建脚本。

Now a makefile can be edited in any way the developer pleases, but there are some good conventions (there is, in fact, a standard ) many follow- and there are tools to auto generate the make files for the library (see automake ) 现在可以以开发人员喜欢的任何方式编辑makefile,但是有一些很好的约定(事实上, 有一个标准 )很多跟随 - 并且有工具可以自动生成库的make文件(参见automake

Makefiles are usually consistent Makefile 通常是一致的

You can simply use the makefile to generate the files, and if it's compliant, the files will be placed in a particular folder (the lib folder I believe?) all queued up and ready to use! 您可以简单地使用makefile生成文件,如果它符合要求,文件将被放置在一个特定的文件夹(我相信的lib文件夹?)所有排队并准备使用!

Keep in mind, a library file is simply the implementation of your code in precompiled format, you could create a library yourself from your code quite easily using the ar tool. 请记住,库文件只是以预编译格式实现代码,您可以使用ar工具轻松地从代码中自行创建库。 Because it is code, just like any other code, you don't necessarily want to include all of the library files for a given library. 因为它是代码,就像任何其他代码一样,您不一定要包含给定库的所有库文件。 For instance with wxWidgets if you're not using rich text, you certainly don't want to waste the extra space in your end executable by including that library file. 例如,对于wxWidgets,如果您不使用富文本,那么您当然不希望通过包含该库文件来浪费最终可执行文件中的额外空间。 Later if you want to use it, you can add it to your project (just like adding a .cpp file) 稍后如果要使用它,可以将其添加到项目中(就像添加.cpp文件一样)

Oh and also with wxWidgets, in their (fantastic) documentation , each module will say what header you need to include, and what library it is a part of. 哦,还有wxWidgets,在他们(精彩)的文档中每个模块都会说出你需要包含什么标题,以及它所属的库。

Happiness 幸福

Libraries are amazing, magical, unicorns of happiness. 图书馆是令人惊叹的,神奇的,幸福的独角兽。 Just try not to get too frustrated with them and they'll prance in the field of your imagination for the rest of your programming career! 尽量不要对他们太过沮丧,他们会在你的编程生涯的其余部分中为你想象的领域腾出一些力量!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM