Code :: Blocks WxWidget错误 - 没有目标!你应该使用wx-config程序编译标志?

时间:2011-11-22 21:57:30

标签: c++ compilation linker wxwidgets codeblocks

我无法获得编译Code :: Blocks的默认WxWidget模板。我收到的错误是error "No Target! You should use wx-config program for compilation flags!(其中包括)

谷歌引导我一些链接,但我似乎无法弄明白

我发现了一个类似的主题; http://forums.codeblocks.org/index.php?topic=10122.0

“问题很可能是,你在非标准目录树中安装了wxwisgets。”

wx-config --list

报告:

wxconf

wx-config --prefix=/opt --list

报告:

wxconfpreopt

这是对的吗?我不知道。

另一个类似的线索; http://www.justlinux.com/forum/archive/index.php/t-105554.html

该主题中的人最终添加g++ 'wx-config --cflags' -o wxTest wxTest.cpp作为编译/链接标志,但我尝试将其添加到Code :: Blocks中的“链接器设置 - >其他链接器选项”,它似乎没有做任何事。

链接:

linkopts

包括:

inclds

我发现整个链接器业务非常混乱,我无法弄清楚我在哪里出错了。

完整错误列表:

/var/wxWidgets-2.8.12/include/wx/defs.h|42|error: #error "No Target! You should use wx-config program for compilation flags!"|
/var/wxWidgets-2.8.12/include/wx/gtk/cursor.h|40|error: ISO C++ forbids declaration of ‘GdkCursor’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/cursor.h|40|error: expected ‘;’ before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/app.h|55|error: ‘guint’ does not name a type|
/var/wxWidgets-2.8.12/include/wx/gtk/app.h|65|error: ISO C++ forbids declaration of ‘GdkVisual’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/app.h|65|error: expected ‘;’ before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/colour.h|26|error: ISO C++ forbids declaration of ‘GdkColor’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/colour.h|26|error: expected ‘,’ or ‘...’ before ‘&’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/colour.h|42|error: ‘GdkColormap’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/colour.h|45|error: ISO C++ forbids declaration of ‘GdkColor’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/colour.h|45|error: expected ‘;’ before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/region.h|59|error: expected ‘)’ before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/region.h|61|error: ISO C++ forbids declaration of ‘GdkRegion’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/region.h|61|error: expected ‘;’ before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/window.h|1133|error: ‘WXWidget’ does not name a type|
/var/wxWidgets-2.8.12/include/wx/window.h|1135|error: ‘WXWidget’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/window.h|1293|error: field ‘m_palette’ has incomplete type|
/var/wxWidgets-2.8.12/include/wx/window.h||In member function ‘wxPalette wxWindowBase::GetPalette() const’:|
/var/wxWidgets-2.8.12/include/wx/window.h|1142|error: return type ‘struct wxPalette’ is incomplete|
/var/wxWidgets-2.8.12/include/wx/window.h|1142|error: ‘m_palette’ was not declared in this scope|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected initializer before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ was not declared in this scope|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: typedef ‘CMPFUNC_wxArraywxArrayGdkWindows’ is initialized (use decltype instead)|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ was not declared in this scope|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘pItem1’ was not declared in this scope|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ was not declared in this scope|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘pItem2’ was not declared in this scope|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ISO C++ forbids declaration of ‘_wxArraywxArrayGdkWindows’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected ‘;’ before ‘&’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected ‘;’ before ‘_wxArraywxArrayGdkWindows’|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ISO C++ forbids declaration of ‘_wxArraywxArrayGdkWindows’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected ‘;’ before ‘&’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected ‘;’ before ‘_wxArraywxArrayGdkWindows’|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ISO C++ forbids declaration of ‘_wxArraywxArrayGdkWindows’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected ‘;’ before ‘&’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: expected ‘;’ before ‘int’|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘CMPFUNC_wxArraywxArrayGdkWindows’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ does not name a type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ does not name a type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|19|error: ‘_wxArraywxArrayGdkWindows’ does not name a type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|132|error: ‘WXWidget’ does not name a type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|171|error: ISO C++ forbids declaration of ‘GtkWidget’ with no type|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|171|error: ‘GtkWidget’ declared as a ‘virtual’ field|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|171|error: expected ‘;’ before ‘*’ token|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|172|error: ‘GtkWidget’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|186|error: ‘GtkWidget’ has not been declared|
/var/wxWidgets-2.8.12/include/wx/gtk/window.h|187|error: ‘GtkWidget’ has not been declared|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|

我理解答案就在我面前的其中一个主题中,但由于我的经验不足,我似乎无法将解决方案应用于我的情况。经过1小时的随机尝试,我放弃了。

1 个答案:

答案 0 :(得分:5)

我没有使用codeblocks的经验,但是wx-config为您提供了使用wxWidgets所需的标志和库。

wx-config --cxxflags

将为您提供编译器标志,例如include目录和#defines。在我的系统上,这给了我

-I/usr/local/lib/wx/include/gtk2-unicode-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread

另一方面

wx-config --libs

将为您提供用于链接的库路径和库。哪个在我的系统上导致

-L/usr/local/lib -pthread   -lwx_gtk2u_xrc-2.9 -lwx_gtk2u_html-2.9 -lwx_gtk2u_qa-2.9 -lwx_gtk2u_adv-2.9 -lwx_gtk2u_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9 

所以你可以只使用这些命令的输出并将它们输入到Code :: Blocks中的相应选项。

另一种方法是使用CMake生成一个简单的wxWidgets应用程序,让它构建Code :: Blocks项目,然后为你自己的应用程序劫持它。