Linking wxWidgets3.1.0 with cmake

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
PTTies
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Jun 09, 2017 8:29 am

Linking wxWidgets3.1.0 with cmake

Post by PTTies »

Hello everyone,

I build wxWidgets-3.1.0 with MSYS with the following commands: ../configure --prefix=/mingw --enable-shared and make && make install. I can run samples such as minimal.cpp without problems. When trying to link wxWidgets in my cmake I get the following errors:

g++.exe: error: /C/wxWidgets-3.1.0/build-release/lib/libwx_baseu_net-3.1.a: No such file or directory
g++.exe: error: /C/wxWidgets-3.1.0/build-release/lib/libwx_mswu_core-3.1.a: No such file or directory
g++.exe: error: /C/wxWidgets-3.1.0/build-release/lib/libwx_baseu-3.1.a: No such file or directory

I checked the lib folder, and these files do exist as you can see at the end of the post.

When running wx-config --libs I get the following output:

-L/C/wxWidgets-3.1.0/build-release/lib -Wl,--subsystem,windows -mwindows /C/wxWidgets-3.1.0/build-release/lib/libwx_mswu_xrc-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_mswu_qa-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_baseu_net-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_mswu_html-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_mswu_adv-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_mswu_core-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_baseu_xml-3.1.a /C/wxWidgets-3.1.0/build-release/lib/libwx_baseu-3.1.a -lwxregexu-3.1 -lwxexpat-3.1 -lwxtiff-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lz -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lcomdlg32 -ladvapi32 -lversion -lwsock32 -lgdi32

The cmake should be fine and the wxWidgets package is found. Below the linking of the wxWidgets library. The second line gives the errors.

Code: Select all

add_executable(GUI ${GUI_BUILD_SOURCES})
target_link_libraries(GUI ${LIBS} ${wxWidgets_LIBRARIES})
Any help is appreciated.

Thanks.
Attachments
wxwidgetslibs.png
wxwidgetslibs.png (70.47 KiB) Viewed 1576 times
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linking wxWidgets3.1.0 with cmake

Post by doublemax »

I've never used MSYS, but are you sure g++ understands the MSYS path format with the /C/ instead of C:/?
I would try changing that for a test-
Use the source, Luke!
PTTies
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Jun 09, 2017 8:29 am

Re: Linking wxWidgets3.1.0 with cmake

Post by PTTies »

Hi,

I hope I understand you right but I think MSYS understands /C/. Whenever I open up an MSYS console and try to go cd /C/ it will should be every folder or file on the C drive so that should be fine. Also the error, "/C/wxWidgets-3.1.0/build-release/lib/libwx_baseu_net-3.1.a: No such file or directory" is the message the MSYS console gives when trying to run the cmake file, not a path I enter manually.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Linking wxWidgets3.1.0 with cmake

Post by doublemax »

Apparently the output from "wx-config --libs" is passed to g++, but does g++ understand the MSYS path format? Any "normal" windows application will not.
Use the source, Luke!
PTTies
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Jun 09, 2017 8:29 am

Re: Linking wxWidgets3.1.0 with cmake

Post by PTTies »

Yes, g++ understands the MSYS pat!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: Linking wxWidgets3.1.0 with cmake

Post by PB »

PTTies wrote:Yes, g++ understands the MSYS pat!
I have never used MSYS (all I know is that I cannot have sh.exe in PATH when using MinGW) but it looks exactly as it does not understand the paths:
1. The compiler says it cannot find the file on that path
2. The file is obviously there (based on your screenshot)

You can test if I'm right, replacing POSIX paths with native MSW ones and see if it helps. ;)

BTW, what CMake generator did you use MSYS Makefiles and not MinGW Makefiles?
Post Reply