How do I use multiple library versions: static, shared, etc 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
CowboyJ
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Nov 16, 2007 3:31 am
Location: Ohio

How do I use multiple library versions: static, shared, etc

Post by CowboyJ »

I am installing wxWidgets on computers using Ubuntu 7.10, Mac OS X 10.4, and WinXP SP2.

Following suggestions from various sources, it seems like building different versions of the libraries is a useful idea. But I began to wonder after I do a "make install" for each version, won't only the last version be available.

After more sudying, I found suggestions that seemed to say don't do "make install", but put a symlink for wx-config in my project directory that refers to the library version location I want to use. That seemed viable, and would only require adjusting my symlink as my library version choice changed. I found other suggestions that talked about using "--prefix=<location of this version>" when I configured my build, and that somehow I could add a prefix element in my invocation of wx-config and it would find the right library version.

Is there a generally-used method to accomplish accessing the desired choice out of several libraries? I understand there probably is, I just have not yet figured out what my research is telling me.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

Most of your question has a Linux flavour, and so does this answer.

As you say, there are various ways to do this, and none of them are wrong. The nearest to an 'official' one that I know is that suggested by Robin Dunn in the wxPython docs. I use slightly adaped version of that.

In the directory in which you extracted the wxWidgets tarball, make a subdir with a descriptive name e.g. 'dynamic-build-unicode-debug'. cd into this, then do:
../configure --with-gtk --enable-debug --enable-unicode --prefix=$(pwd)
(note the inital '..') and 'make'. You now have a 'local' build of that type, with its libraries in dynamic-build-unicode-debug/lib . Repeat ad lib in other subdirs, with the options of your choice: --disable-shared, --with-x11 etc.

What about your app? The best answer is to put the files in a separate dir, then symlink them to a subdir of each wx build; that way you don't have multiple copies to alter when you make changes. For historical reasons I add an extra level, so my app is at the same level as the samples. My dir structure therefore looks like:
~/MyProjectFiles
~/wxWidgets/wxGTK-2.8.6/dynamic-build-unicode-debug/projects/MyProject
~/wxWidgets/wxGTK-2.8.6/static-build-ansi-release/projects/MyProject
...
~/wxWidgets/wxGTK-2.6.4/dynamic-build-unicode-debug/projects/MyProject
etc

(And, no, I don't really use such long subdir names ;) )

So each MyProject dir contains symlinks to the code in ~/MyProjectFiles, plus 'configure', 'install.sh' etc. To create a makefile for a configuration, I just have to do, in a shell:
PATH=../..:$PATH && ./configure
This ensures that the wx-config from the wx build dir is the first one in the PATH, so the resulting makefile contains the correct flags and lib paths. Then when I want to build my app with those options, I just have to cd to ~/wxWidgets/wxGTK-2.8.6/dynamic-build-unicode-debug/projects/MyProject or whichever, and do 'make'.

If you don't use (bakefile/)autotools/configure, you can get the same result by doing PATH=../..:$PATH in the shell before using the standard:
g++ -g myfoo.cpp `wx-config --libs --cxxflags` -o myfoo
build line. But you have to set the PATH like this each time you open a shell, not just once.

That sounds like a lot of work, but it's actually a lot easier to do than to describe, I have multiple builds of multiple wx versions happily co-existing, without any clashes, and can select which to use just by opening the shell in the appropriate dir. It also doesn't stop you installing your distro's standard package, the 2.8.4 .deb in the case of ubuntu gutsy, and creating a deb of your app against it, as you'll want to do when you distribute.

Regards,

David
zhouhao
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2005 7:02 am

Post by zhouhao »

Is it possible to use the same wx-config for different build/version? For example, I want to build one application in this way 'wx-config --version=2.8 --debug=no --static=yes --cflags` and to build another application in another way 'wx-config --version=2.9 --debug=yes --static=no --unicode=no`?
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

zhouhao wrote:Is it possible to use the same wx-config for different build/version? For example, I want to build one application in this way 'wx-config --version=2.8 --debug=no --static=yes --cflags` and to build another application in another way 'wx-config --version=2.9 --debug=yes --static=no --unicode=no`?
if you 'make install' all of them it should be possible
though using them in different folders is often cleaner and less error-prone
Post Reply