在CLion上构建wxWidgets 3.0.3程序(windows)

时间:2017-10-11 02:16:56

标签: c++ cmake wxwidgets clion

Building wxWidgets 3.1.0 on CLion (Ubuntu)

Getting started with wxWidgets and CLion?

要了解这些问题,我可以运行Wxwidgets GUI“hello world”程序,使用wxwidgets 3.0.3。

My screenshot

但是我不能以同样的方式运行其他wxwidgets样本,例如grid aui ribbon advance GUI。这些GUI样本可以在我的CODE :: BLOCKS上运行。

OS:Server 2016

克利翁:2017年2月3日

的wxWidgets:3.0.3

码::块:16.01

MingW:x86_64-4.9.3-win32-seh-rt_v4-rev1

我的cmakelist.txt在研究了每个地方(wxconfig.exe都复制到cmake bin字典)之后如下:
修改cmakelist,

 cmake_minimum_required(VERSION 3.9)
project(HelloTest)

#set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

find_package(wxWidgets REQUIRED
        core base aui html jpeg tiff png gif zlib
#        adv dbgrid expat html jpeg ribbon
#        media mono net png propgrid qa
#        regex ribbon  richtext scintilla
#        stc tiff webview  xml xrc zlib
        )

include(${wxWidgets_USE_FILE})

include_directories(D:/IDE/wxWidgets-3.0.3/samples)
set(SOURCE_FILES auidemo.cpp)
add_executable(HelloTest ${SOURCE_FILES})
target_link_libraries(HelloTest ${wxWidgets_LIBRARIES})

但是我得到了一些错误,如下所示

CMakeFiles\HelloTest.dir/objects.a(auidemo.cpp.obj): In function `MyFrame::CreateGrid()':
D:/IdeaProjects/HelloTest/auidemo.cpp:1568: undefined reference to `wxGrid::CreateGrid(int, int, wxGrid::wxGridSelectionModes)'
CMakeFiles\HelloTest.dir/objects.a(auidemo.cpp.obj): In function `wxGrid::wxGrid(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)':
D:/IDE/wxWidgets-3.0.2/include/wx/generic/grid.h:944: undefined reference to `wxGrid::Init()'
D:/IDE/wxWidgets-3.0.2/include/wx/generic/grid.h:946: undefined reference to `wxGrid::Create(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)'
CMakeFiles\HelloTest.dir/objects.a(auidemo.cpp.obj):auidemo.cpp:(.rdata$.refptr.wxGridNameStr[.refptr.wxGridNameStr]+0x0): undefined reference to `wxGridNameStr'
CMakeFiles\HelloTest.dir/objects.a(auidemo.cpp.obj):auidemo.cpp:(.rdata$.refptr._ZTV6wxGrid[.refptr._ZTV6wxGrid]+0x0): undefined reference to `vtable for wxGrid'
D:/IDE/wxWidgets-3.0.2/lib/gcc_lib/libwxmsw30ud_aui.a(auilib_floatpane.o):floatpane.cpp:(.rdata$.refptr._ZN11wxMiniFrame12ms_classInfoE[.refptr._ZN11wxMiniFrame12ms_classInfoE]+0x0): undefined reference to `wxMiniFrame::ms_classInfo'
D:/IDE/wxWidgets-3.0.2/lib/gcc_lib/libwxmsw30ud_aui.a(auilib_floatpane.o):floatpane.cpp:(.rdata$.refptr._ZTV11wxMiniFrame[.refptr._ZTV11wxMiniFrame]+0x0): undefined reference to `vtable for wxMiniFrame'
D:/IDE/wxWidgets-3.0.2/lib/gcc_lib/libwxmsw30ud_html.a(htmllib_m_image.o): In function `wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface*, wxFSFile*, int, bool, int, bool, double, int, wxString const&)':
C:\wxWidgets-3.0.2\build\msw/../../src/html/m_image.cpp:393: undefined reference to `wxGIFDecoder::wxGIFDecoder()'
C:\wxWidgets-3.0.2\build\msw/../../src/html/m_image.cpp:394: undefined reference to `wxGIFDecoder::LoadGIF(wxInputStream&)'
D:/IDE/wxWidgets-3.0.2/lib/gcc_lib/libwxmsw30ud_html.a(htmllib_htmlfilt.o):htmlfilt.cpp:(.rdata$.refptr._ZTV20wxStringOutputStream[.refptr._ZTV20wxStringOutputStream]+0x0): undefined reference to `vtable for wxStringOutputStream'

1 个答案:

答案 0 :(得分:0)

    1.I use "mingw32-make -j 8 -f makefile.gcc BUILD=debug MONOLITHIC=0 SHARED=0 UNICODE=1 USE_GUI=1 USE_OPENGL=1 USE_ODBC=1 RUNTIME_LIBS=static MSLU=1 VENDOR=..  CXXFLAGS=-std=gnu++11 -Wall",The Clion can't compile the sample code.

    2.when I use "mingw32-make -j 8 -f makefile.gcc BUILD=debug ***MONOLITHIC=1*** SHARED=0 UNICODE=1 USE_GUI=1 USE_OPENGL=1 USE_ODBC=1 RUNTIME_LIBS=static MSLU=1 VENDOR=..  CXXFLAGS=-std=gnu++11 -Wall"",all the andvance GUI sample code can be compile and run.

    3.Follow the offical doc,The vision of MingW “x86_64-4.9.3-win32-seh-rt_v4-rev1” be used .it's working well.

    4.I have try the other vison MingW ,it's not working.

screen shot

另一方面,如果我们编译Wxwidgets使用“MONOLITHIC = 0”,我们必须按顺序链接libxxx.a。并添加“-lcomctl32”选项,我的新cmakelist.txt如下。该工作正常;

    cmake_minimum_required(VERSION 3.8)
project(NewTestWxAdv)

set(CMAKE_CXX_STANDARD 11)
include_directories(
        includes
        D:/IDE/wxWidgets-3.0.3/include
#        D:/IDE/wxWidgets-3.0.3/lib/gcc_lib/mswud
        D:/IDE/wxWidgets-3.0.3/lib/gcc_lib/mswu
)
link_directories(
        D:/IDE/wxWidgets-3.0.3/lib/gcc_lib
)

set(
        WX_LIBS
#        libwxmsw30ud_propgrid.a
#        libwxmsw30ud_ribbon.a
#        libwxmsw30ud_stc.a
#        libwxmsw30ud_webview.a
#        libwxmsw30ud_gl.a
#        libwxmsw30ud_richtext.a
#        libwxmsw30ud_xrc.a
#        libwxmsw30ud_aui.a
#        libwxmsw30ud_html.a
#        libwxmsw30ud_adv.a
#        libwxmsw30ud_core.a
#        libwxbase30ud_xml.a
#        libwxbase30ud_net.a
#        libwxbase30ud.a
#        libwxscintillad.a
#        libwxtiffd.a
#        libwxjpegd.a
#        libwxpngd.a
#        libwxzlibd.a
#        libwxregexud.a
#        libwxexpatd.a
#        libwxmsw30ud_media.a

        libwxmsw30u_propgrid.a
        libwxmsw30u_ribbon.a
        libwxmsw30u_stc.a
        libwxmsw30u_webview.a
        libwxmsw30u_gl.a
        libwxmsw30u_richtext.a
        libwxmsw30u_xrc.a
        libwxmsw30u_aui.a
        libwxmsw30u_html.a
        libwxmsw30u_adv.a
        libwxmsw30u_core.a
        libwxbase30u_xml.a
        libwxbase30u_net.a
        libwxbase30u.a
        libwxscintilla.a
        libwxtiff.a
        libwxjpeg.a
        libwxpng.a
        libwxzlib.a
        libwxregexu.a
        libwxexpat.a
        libwxmsw30u_media.a
)

set(SOURCE_FILES aui.cpp)
add_executable(NewTestWxAdv ${SOURCE_FILES})
target_link_libraries(
        NewTestWxAdv
        ${WX_LIBS}
        -lcomctl32
)