wxWidgets C++ 3.1.1 works in VS, not in Linux!

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
derek_ly
In need of some credit
In need of some credit
Posts: 6
Joined: Tue Jun 05, 2018 9:09 pm

wxWidgets C++ 3.1.1 works in VS, not in Linux!

Post by derek_ly »

Hello All,

Hope everyone is doing well! I currently have an issue with moving my code from Visual Studio 2013 - wxWidgets C++ 3.1.1 to a linux platform. Everything works perfectly in VS2013, so I imported the source.cpp files over, and the entire files over, to a linux based host machine. I've downloaded the linux bz2 files from wxWidget home page. Extracted that on my windows machine and transferred everything to the linux.

After that, I began to config/build on the linux. I went to the wxWidgets-3.1.1 folder, made a directory called gtk-build(I was on google the entire day and this was what everyone was using) and ../configure "etc etc". After all of the make/install/path directory. I compiled my code.

Name of File: Source.cpp

g++ Source.cpp `wx-config --cxxflags` `wx-config --libs`

Attached below is the picture of errors that I had gotten. The very first line is my declaration for compilation. Now my question is, why is this happening (maybe it's a really basic question)? Shouldn't the g++ know that the code is using wxWidgets syntax? A lot of the errors were for wxStrings/wxEVENT_Buttons/etc.

Can anyone explain to me what are my steps forward here? I've read through the documentations that wxWidgets is cross-platform, and I thought that i would literally just be simple as recompiling and running it on the linux machine. Am I missing something? Some steps?

Thank you so much for all of your help! Please let me know if there are any points/statements that I need to clarify and/or show more!

Can't appreciate it enough!

- Derek
Attachments
Error_Compilation.PNG
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets C++ 3.1.1 works in VS, not in Linux!

Post by doublemax »

The first thing to do is to build the "minimal" sample that comes with wxWidgets.

Go to <wxdir>/gtk-build/samples/minimal/ and use the exact same "make..." command that you used when building the wxWidgets libraries. If that compiles and the executable runs, you know that everything is fine on the wx side.

Post the output of
wx-config --cxxflags
and
wx-config --libs
Use the source, Luke!
derek_ly
In need of some credit
In need of some credit
Posts: 6
Joined: Tue Jun 05, 2018 9:09 pm

Re: wxWidgets C++ 3.1.1 works in VS, not in Linux!

Post by derek_ly »

Hey again DoubleMax,

Attached below are the pictures for the minimal run and the wxconfig for both of the --cxxflags/--libs.

The minimal sample is NOT running. I feel like I've made a mistake somewhere with make install or something is missing.

Thanks again!

- Derek
Attachments
wxconfig.PNG
wxconfig.PNG (22.72 KiB) Viewed 1856 times
minimal.PNG
minimal.PNG (52.1 KiB) Viewed 1856 times
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets C++ 3.1.1 works in VS, not in Linux!

Post by doublemax »

The wx-config outputs still point to wx 2.8, so something is wrong there.

As i don't work under Linux, i can't tell you how to fix it, but there must be several threads about this in this sub forum.

Or wait until one of the Linux people comes to help.
Use the source, Luke!
User avatar
marcelinux
Knows some wx things
Knows some wx things
Posts: 40
Joined: Thu Nov 07, 2013 9:59 pm
Location: Madrid, Spain

Re: wxWidgets C++ 3.1.1 works in VS, not in Linux!

Post by marcelinux »

I'm not an expert but installed wxWidgets several times using the wiki. Ubuntu and Debian distros.
https://wiki.wxwidgets.org/Compiling_an ... ng_started
Currently, I have included wx repositories in my sources.list
https://wiki.wxwidgets.org/Installing_a ... der_Ubuntu

Edit: Sorry. I included CodeLite repositories in sources.list
wxWidgets from git and self-compiled.
Last edited by marcelinux on Fri Jun 08, 2018 4:26 pm, edited 1 time in total.
I just need learn a little bit more. Thank you for your help.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxWidgets C++ 3.1.1 works in VS, not in Linux!

Post by DavidHart »

Hi,
made a directory called gtk-build(I was on google the entire day and this was what everyone was using)
Heh. The name of the subdir matters little.

What matters more is your ../configure statement. What does "etc etc" stand for? In particular, does it include '--prefix=' and, if so, which path did you put there?

It's entirely reasonable to have >1 wx build 'installed', and for them peacefully to coexist. However you need to do something to ensure that, when you build a wx program, the correct wx-config is used. 'Something' can vary e.g. some distros use update-alternatives. However two reliable ways are to specify its full path in your invocation:

Code: Select all

g++ foo.cpp `/full/path/to/wx-config --cxxflags --libs`-o foo
or to prepend the path to that terminal's PATH:

Code: Select all

export PATH=/full/path/to/:$PATH
g++ foo.cpp `wx-config --cxxflags --libs`-o foo
In an IDE you'd either use the first method or, more conveniently, set an environmental variable (some IDEs will have an way of doing this for internal use) to /full/path/to/ and use that in the IDE's compiler and linker settings.

Regards,

David
Post Reply