How to statically link applications to wxWidgets via Visual Studio 2008 and in Linux

MS Windows Procedure:

Build the wxWidgets as static
  1.  Uncompressed the source file “wxWidgets-2.8.12.tar.gz”
  2. Go to “..\wxWidgets-2.8.12\build\msw”
  3.  Right-click and open the file “wx.dsw” using Visual Studio 2008
  4. Change the “Runtime Library” property value into “Multi-threaded (/MT)”
  5. Rebuild the solution as “Release” mode
  6. The libraries can be found in “..\wxWidgets-2.8.12\lib\vc_lib”














Build the application to link with wxWidgets as static
  1. Add environment variable (for convinience) WXWIN and set the value to wherever your wxWidgets is located. Sample: c:\wxWidgets
  2. Open your application in Visual Studio 2008 and switch the mode to “Release”
  3. “Preprocessor Definitions” must be set to:

    WIN32
    __WXMSW__
    _WINDOWS
    NOPCH
    _CRT_NONSTDC_NO_DEPRECATE  












     
 4. Change the “Runtime Library” property value into “Multi-threaded (/MT)”













      
 5. “Additional Library Directories” property value into “"$(WXWIN)\lib\vc_lib"”














       
6. “Additional Dependencies” property value into:


"$(WXWIN)\lib\vc_lib\wxbase28.lib"

"$(WXWIN)\lib\vc_lib\wxmsw28_adv.lib"
"$(WXWIN)\lib\vc_lib\wxmsw28_core.lib"
"$(WXWIN)\lib\vc_lib\wxmsw28_aui.lib"
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib 















6. Rebuild your application and execute without any wxWidgets runtime DLLs installed


SUSE Linux Procedure:

Build the wxWidgets as static

1. Uncompressed the source file “wxWidgets-2.8.12.tar.gz”
2.  Go to “..\wxWidgets-2.8.12\build
3. Create new folder by issuing command in xterm "mkdir new_build"
4. Go inside the "new_build" folder by issuing command in xterm "cd new_build"
5. Issue command in xterm "../configure --disable-shared --enable-monolithic"
6. Issue the command in xterm "make"
7. Issue the command in xterm "make install". The libraries are installed in "/usr/local/lib"
8. Issue the command in xterm "ldconfig"

Build the application to link with wxWidgets as static

1. In the folder where your source files are located (*.cpp, *.h) issue the command
     in xterm "g++ *.cpp `wx-config --libs --cxxflags` -o MyApp"
2. At this time your executable file "MyApp" is created. You can now run this file without needing to install
    SO of wxWidgets.
 

That's it! =)

Comments

  1. Thank you for this very good example! I've been searching for this for sometimes and your example is the best!!

    ReplyDelete

Post a Comment

Popular posts from this blog

Creating tray application and popup context menu in Windows

How to implement mouse drag using wxWidgets

How to put an image to wxPanel using wxWidgets