Code::Blocks: building a program with static lib Topic is solved

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
lpx
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 13, 2017 4:54 am

Code::Blocks: building a program with static lib

Post by lpx »

I tried to build a program with static lib, I did not choose "use wxwidgets dll" in the project wizard.
2.png
2.png (45.64 KiB) Viewed 2442 times
at first I neglected the following step
3.png
3.png (43.38 KiB) Viewed 2442 times
which turned out unable to compiled.
selecting all in this step won compile either. I searched how to build a static link and some said instead of selecting all, some libraries should not be selected:
4.png
4.png (43.07 KiB) Viewed 2442 times
then the program can be compiled, and runs without dll.

I don't think I understood the meaning of "additional libraries", as those libraries, at least some of the libraries seem to be necessary instead of additional. Have I mixed any concepts?
Then I am wondering if there's a setting that allows the compiler to auto-select the libraries the program requires, for I really don't want to manually select libraries every time I build a project. And I believe the "hello world program" doesn't in fact require all the libraries selected, will this increase the size of the exe?

And I also find a problem when I want to create both release and debug version of the program. I tick both in the wizard, but the bin file contains only the debug version. If I tick release only, then there will be a release version. Does this mean that CB only builds one version a time? Then how can I build both versions?

Edit: Subject edited to reflect that it's a Code::Blocks question.
DavidHart. Moderator
Last edited by DavidHart on Fri Aug 18, 2017 2:13 pm, edited 1 time in total.
Reason: Change the topic to reflect that it's a Code::Blocks question
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Code::Blocks: building a program with static lib

Post by ONEEYEMAN »

Hi,
1. All those libraries that are displayed as "Additional libraries" are in fact additional libraries. Let me explain.
There are only 2 main libraries in wxWidgets - wxBase and wxCore. wxBase is the library that contains all non-GUI stuff - string and STL-like classes. wxCore is the library that contains all standard GUI control (frame, button, list, combo box, etc).

Now, here are the list of an additional libraries as it appears in the list:

- wxXrc - this is the library that contains the resource handling. If you look at Windows MSVC, you will see that it is able to create different resources (dialogs, bitmaps, etc) and store it in the rc (resource) file. Then the program can read this rc file and create an actual windows/resources/etc on the screen. This library will do essentially the same thing - load the externally created resources and generate the appropriate resources on the screen.

- wxDbGrid/wxOdbc - those libraries were available up to version 2.8. They were removed in version 3.0. They are basically a wrapper around the ODBC Open Source library called iODBC. They were removed in favour of the programmer using something that is explicitly designed to work with databases.

- wxMedia - this is the library that wraps around native media control. It will allow the developer to create a native movie/music player and play movie/music.

- wxNet - this library contains classes that wraps around the network accesses (HTTP, FTP, sockets).

- wxGl - a wraper around OpenGL (3D rendering framework).

-wxQa - some additional classes to do testing/quality assurance. They were used in the past but nowadays nobody uses it probably.

- wxXml - a library that is used to read, parse and write an XML files.

- wxAdv - this is an advanced library that contains some advanced controls (namely wxGrid and wxOwnerDrawnComboBox being the biggest 2).

- wxHtml - same as wxXml buit for HTML4. No HTML5 support is available.

- wxJpeg, wxTiff - the are the wrappers around library that reads and writes the appropriate bitmapo formts.

- wxRegex - this library will soon be obsolete in favour of the standard regex in c++11. But since wxWidgets still supports an older compiler this will not happen very soon. ;-)

- wxExpat - it is a wxWidgets wrapper around expat XML parsing library.

Now only you as a developer of the software that uses wxWidgets will know what features you program will use. And therefore you will know which libraries besides wxBase and wxCore you will need to link against. Now most, ifnot all, of the current linkers are smart enough to choose the required libraries according to the propgram needs. So if you link against all of them its not an error. However it is better to not to do that and link only the library that your program needs. Just refer to the explanation above.

2. The C::B IDE probably is not smart enough and can't compile 2 different configurations at one shot. You just need to create a new configuration and switch to the new configuration and build it independently. I don't have an experience working with this IDE, so can't tell for sure. I know MSVC is able to do that, since it has a menu "Build->Batch Build..." where you can select multiple configuration t be built. But I have no idea about C::B. You will just have to build it one by one.

Thank you.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Code::Blocks: building a program with static lib

Post by Manolo »

C::B does allow compiling all "targets" (debug, release, or whatever you have created) in one shot.
lpx
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 13, 2017 4:54 am

Re: Code::Blocks: building a program with static lib

Post by lpx »

ONEEYEMAN wrote:Hi,
1. All those libraries that are displayed as "Additional libraries" are in fact additional libraries. Let me explain.
There are only 2 main libraries in wxWidgets - wxBase and wxCore. wxBase is the library that contains all non-GUI stuff - string and STL-like classes. wxCore is the library that contains all standard GUI control (frame, button, list, combo box, etc).


......
THANK YOU VERY MUCH, ONEEYEMAN. Your detailed explanation is very helpful!
Indeed, I have another question: what if I link the additional library to a dynamically linked program? Building a program with dlls does not require any of the additional libraries, at least it works if I don't choose any, but it requires dlls. So if I linked those libraries, does it mean that the program eventually won't rely on dlls?
lpx
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 13, 2017 4:54 am

Re: Code::Blocks: building a program with static lib

Post by lpx »

Manolo wrote:C::B does allow compiling all "targets" (debug, release, or whatever you have created) in one shot.
Thanks for replying.
I asked the question because I chose both versions in the "wizard":
1.png
1.png (46.21 KiB) Viewed 2402 times
but I only get the debug version in the bin file. I checked settings in "properties", it looks like this:
6.png
6.png (50.94 KiB) Viewed 2402 times
7.png
7.png (50.92 KiB) Viewed 2402 times
I don't see any problem here. Maybe I should check the compiler option?
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 465
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Code::Blocks: building a program with static lib

Post by New Pagodi »

Are you asking you to change which target to build? If so, you can do this by selecting a different target in the toolbar
toolbar.png
toolbar.png (5.84 KiB) Viewed 2394 times
or in the build menu.
menu.png
menu.png (20.92 KiB) Viewed 2394 times
After making the change, the build command will build the new target.
lpx
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 13, 2017 4:54 am

Re: Code::Blocks: building a program with static lib

Post by lpx »

New Pagodi wrote:Are you asking you to change which target to build? If so, you can do this by selecting a different target in the toolbar
or in the build menu.
Thanks a lot!
Post Reply