CodeBlocks: How to build C++ App w using wxWidgets library DLLs

浪尽此生 提交于 2019-12-25 01:43:34

问题


I have downloaded and installed binaries of wxWidgets and Codeblocks onto my PC with Windows 10. Codeblocks builds and runs HelloWorld. With Codeblocks I then open an existing DEV-C++ project which uses wxWidgets - Codeblocks compiles this with no problems, but the linker fails with a message that a library dll file of Widgets is an "unrecognized format". have spent several hours looking for help on this forum and on the widgets site. I have read about Export Libraries which bridge the gap between the calls in the App and the functions in the shared DLLs, but have failed to find them. What is the correct way to link to the Widgets library? Thank you for any help you can give me.


回答1:


I would suggest building the wxWidgets libraries with code:blocks from source, rather than downloading a binary library that was built with an unknown compiler

Here are instructions to build the wxWidgets static libraries with code:block. Ti build DLLs, modify step 8. ( Note that your applications will start faster if you use the static library.

Download wxWidgets source code from https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.0/wxWidgets-3.1.0.7z

Unpack to a folder. On my system, I use C:\Users\James\code\wxwidgets-3.1.0

Open a command window.

cd to the code::blocks mingw folder. On my system this is C:\Program Files (x86)\CodeBlocks16\MinGW

Type mingwvars.bat

cd to wxwidgets folder. On my system C:\Users\James\code\wxwidgets-3.1.0

cd to ./build/msw

Type mingw32-make SHELL=CMD.exe -j4 -f makefile.gcc BUILD=release UNICODE=1 SHARED=0 MONOLITHIC=1 If you get strange 'file not found' errors you will need to edit the makefile - details are here http://stackoverflow.com/a/41498057/16582

Set code::blocks global variable wxwidgets as follows:

base                      C:\Users\James\code\wxWidgets-3.1.0
include                   C:\Users\James\code\wxWidgets-3.1.0\include
lib                       C:\Users\James\code\wxwidgets-3.1.0\lib\gcc_lib
setup ( user-defined )    C:\Users\James\code\wxWidgets-3.1.0\lib\gcc_lib\mswu


来源:https://stackoverflow.com/questions/47115323/codeblocks-how-to-build-c-app-w-using-wxwidgets-library-dlls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!