wxWidgets 大量未定义的引用 [英] wxWidgets lots of undefined references
问题描述
我将源代码下载到最新的 wx 并设法编译它,没有任何问题.
I downloaded the source to the latest wx and managed to compile it without any issues.
配置:
../configure --enable-optimise --enable-stl --enable-unicode --enable-threads --enable-static --disable-shared --prefix=/usr/local
当我尝试编译这个示例时:
g++-4.8 `wx-config --libs` `wx-config --cxxflags` test.cpp
我收到很多未定义的引用(完整列表这里)
I get alot of undefined refferences ( full list here )
我怎样才能做到这一点?
How can I make this work?
推荐答案
当使用静态库时,正如你所做的(因为 --disable-shared
在配置命令行中),这些库必须来在 引用它们的目标文件之后(这是所有 Unix-ish 链接器的一般规则,尤其是 GNU ld).所以正确的命令行应该是
When using static libraries, as you do (because of --disable-shared
in configure command line), the libraries must come after the object file that references them (this is a general rule with all Unix-ish linkers and definitely with GNU ld). So the correct command line would be
g++-4.8 `wx-config --cxxflags` test.cpp `wx-config --libs`
或者,只是为了保持简短,并且因为编译标志出现在何处无关:
or, just to keep it short, and because it does not matter where do the compilation flags appear:
g++-4.8 test.cpp `wx-config --cxxflags --libs`
这篇关于wxWidgets 大量未定义的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!