Command-line command for compiling and linking a wx app

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
SSteven
Earned a small fee
Earned a small fee
Posts: 15
Joined: Fri Sep 04, 2015 7:03 am

Command-line command for compiling and linking a wx app

Post by SSteven »

Hi

I'm trying to compile and link my _first_ wx program (the sample program in the wx docs) from the command line. Which command should be used from the command line for compiling and linking? I have tried finding this command on the wx site but am unable to do so; hence the query.

I have already compiled the wx source on my Windows PC and have successfully created a set of static libraries (*.a) in the lib\gcc_libs folder of the wx Installation folder.

The following Env vars on my system have been defined:
1) MINGW refers to the GCC compiler executable's folder.
2) WXWIN refers to the WX installation folder.

Thanks
Steven
SSteven
Earned a small fee
Earned a small fee
Posts: 15
Joined: Fri Sep 04, 2015 7:03 am

Re: Command-line command for compiling and linking a wx app

Post by SSteven »

Hi

I used the following BAT file to compile and link the "Hello World" wx program:

F:
CD \Files\C\SW\Applications\Samples\C++Samples\wxwidgets\HelloWorld0

g++ -o HelloWorldwx.exe -ID:\Libs\wxWidgetsStaticLib\include HelloWorldwx.cpp -LD:Libs \wxWidgetsStaticLib\lib -llibwxbase30ud.a -LD:Libs\wxWidgetsStaticLib\lib -llibwxmsw30ud_core.a

PAUSE

HelloWorldwx

The compilation starts but the compiler issues an error saying file "setup.h" is missing.

I searched a bit and found one "setup.h" file in some sub-folder of wx and copied it to the right place. But then the compilation (proper) fails, giving several errors.

Can anyone help? Thanks

Steven
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Command-line command for compiling and linking a wx app

Post by catalin »

Building wxW libs is rather simple, by running the following command in %WXWIN%\build\msw :
mingw32-make.exe -f makefile.gcc
There are multiple options that can be changed from the default values, but for a first "hello world" I guess you don't need to.

When building your code you should keep the same options, same relevant paths etc. In order to do that the easiest way IMO is to go to samples/minimal, edit minimal.cpp to contain your code, and run the same command there (it will obviously pick up the makefile from the sample folder).

Good luck!
SSteven
Earned a small fee
Earned a small fee
Posts: 15
Joined: Fri Sep 04, 2015 7:03 am

Re: Command-line command for compiling and linking a wx app

Post by SSteven »

Hi

Thanks for the guidance. I have tried it and confirm it works!

Thanks
Steven
Post Reply