Author Topic: Linking release build without DLLs in Windows  (Read 4266 times)

beethoven62

  • Guest
Linking release build without DLLs in Windows
« on: April 04, 2008, 07:16:01 pm »
Hi all,

I've been using CodeBlocks (SVN 4977) with wxWidgets (2.8.7) to develop an application of mine. After many hours of installation and reinstallation of wxWidgets using various build options under MinGW, I've gotten my app to compile in debug and release builds. However, these builds require the wxWidgets DLL to be present. I would like to link my app as a release build without having to have the wxWidgets DLL accompany my .exe file. Before you answer, let me say that I've tried many methods to get CodeBlocks to compile and link my app (no DLL release) with no success. I've compiled wxWidgets using the following options:

mingw32-make.exe -f makefile.gcc USE_XRC=1 SHARED=0 MONOLITHIC=1 RUNTIME_LIBS=static BUILD=release UNICODE=1

A gcc_lib directory is created with the following files:

libwxexpat.a
libwxjpeg.a
libwxmsw28u.a
libwxpng.a
libwxregexu.a
libwxtiff.a
libwxzlib.a

...and a directory: mswu

In CodeBlocks I've set up the following build option called ReleaseNoDLL:

Compiler settings (Policy: Append target options to project options):

Compiler Flags that are checked:
Strip all symbols from binary (minimizes size) [-s]
Optimize even more (for speed) [-O2]

Other options and #defines are blank

Linker settings (Policy: Prepend target options to project options):

Link libraries:
libwxmsw28u.a
libwxpng.a
libwxjpeg.a
libwxtiff.a
libwxzlib.a

Search directories (Policy: Append target options to project options):

Compiler:
C:\wxMSW-2.8.7\lib\gcc_lib\mswu

Linker:
C:\wxMSW-2.8.7\lib\gcc_lib

Resource Compiler:
C:\wxMSW-2.8.7\lib\gcc_lib\mswu

Nothing added for the other tabs (Pre/post build step, Custom variables, "Make" commands)

For the overall project build (covers Debug, Release, and ReleaseNoDLL builds) I've set up the following:

Compiler settings:

Compiler Flags that are checked:
Enable all compiler warnings (overrides every other setting) [-Wall]

Other options:
-pipe
-mthreads
[[if (PLATFORM == PLATFORM_MSW && (GetCompilerFactory().GetCompilerVersionString(_T("gcc")) >= _T("4.0.0"))) print(_T("-Wno-attributes"));]]
-Winvalid-pch
-include wx_pch.h

#defines
__GNUWIN32__
__WXMSW__
wxUSE_UNICODE
WX_PRECOMP

Linker settings:

Link libraries are blank

Search directories:

Compiler:
C:\wxMSW-2.8.7\include
C:\wxMSW-2.8.7\contrib\include

Linker is blank

Resource Compiler:
C:\wxMSW-2.8.7\include

Nothing added for the other tabs (Pre/post build step, Custom variables, "Make" commands)

When the new build was created I chose the wxWidgets build with the following in the configuration options window:

Use wxWidgets DLL unchecked
wxWidgets is built as a monolithic library checked
Enable unicode checked
Create Empty Project unchecked
Create and use precompiled header (PCH) checked
Configuration: left blank
Configure Advanced Options unchecked

Finally, when I try to build using the ReleaseNoDLL build option, I get the following linker errors:

||=== LcnGui, ReleaseNoDLL ===|
||warning: ./wx_pch.h.gch/Debug_wx_pch_h_gch: created using different flags|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x44)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x60)||undefined reference to `_imp___ZN12wxStringBase8InitWithEPKwjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xbb)||undefined reference to `_imp___ZN12wxStringBase10ConcatSelfEjPKwj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xec)||undefined reference to `_imp___ZN12wxStringBase10ConcatSelfEjPKwj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x16c)||undefined reference to `_imp___ZN12wxWindowBase5CloseEb'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x1db)||undefined reference to `_imp___Z11wxGetLocalev'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x212)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x230)||undefined reference to `_imp___ZN12wxStringBase8InitWithEPKwjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x260)||undefined reference to `_imp___Z12wxMessageBoxRK8wxStringS1_lP8wxWindowii'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x393)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x3b3)||undefined reference to `_imp___ZN12wxStringBase8InitWithEPKwjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x440)||undefined reference to `_imp___ZN8wxString6PrintfEPKwz'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x5e7)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x612)||undefined reference to `_imp___ZN12wxStringBase8InitWithEPKwjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x7e1)||undefined reference to `_imp___ZN12wxStringBase6appendEjw'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x804)||undefined reference to `_imp___ZNK8wxString5RightEj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x8a4)||undefined reference to `_imp___ZNK8wxString4LeftEj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x8c0)||undefined reference to `_imp___ZN12wxStringBaseaSERKS_'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x901)||undefined reference to `_imp___ZNK8wxString4FindEwb'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x927)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x947)||undefined reference to `_imp___ZNK8wxString3MidEjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x961)||undefined reference to `_imp___ZN12wxStringBaseaSERKS_'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x9c9)||undefined reference to `_imp___ZN8wxString7ReplaceEPKwS1_b'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x9f5)||undefined reference to `_imp___ZN8wxString7ReplaceEPKwS1_b'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xa1f)||undefined reference to `_imp___ZN8wxString7ReplaceEPKwS1_b'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xa49)||undefined reference to `_imp___ZN8wxString7ReplaceEPKwS1_b'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xa5e)||undefined reference to `_imp___ZN8wxString4TrimEb'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xa76)||undefined reference to `_imp___ZN8wxString4TrimEb'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xa94)||undefined reference to `_imp___ZNK8wxString4FindEwb'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xab2)||undefined reference to `_imp___ZNK8wxString3MidEjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xad7)||undefined reference to `_imp___ZNK8wxString8ToDoubleEPd'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xc25)||undefined reference to `_imp__wxConvUTF8'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xc31)||undefined reference to `_imp___ZNK8wxString6mb_strERK8wxMBConv'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xc8e)||undefined reference to `_imp___ZN8wxString8TruncateEj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xd74)||undefined reference to `_imp___ZNK8wxString5RightEj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xe7d)||undefined reference to `_imp___ZNK8wxString4FindEwb'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xe87)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xea3)||undefined reference to `_imp___ZNK8wxString3MidEjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xec7)||undefined reference to `_imp___ZNK8wxString8ToDoubleEPd'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xf42)||undefined reference to `_imp___Z10wxLogErrorPKwz'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xfaf)||undefined reference to `_imp___ZN8wxThread6CreateEj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0xfc9)||undefined reference to `_imp___Z10wxLogErrorPKwz'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x101d)||undefined reference to `_imp___ZN8wxThread3RunEv'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x10a4)||undefined reference to `_imp___ZN8wxThread6DeleteEPPv'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x10af)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x10d0)||undefined reference to `_imp___ZN12wxStringBase8InitWithEPKwjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x11d8)||undefined reference to `_imp___ZN12wxStringBase4nposE'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x11fc)||undefined reference to `_imp___ZN12wxStringBase8InitWithEPKwjj'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x1223)||undefined reference to `_imp___ZN8wxRegKeyC1ERK8wxString'|
obj\ReleaseNoDLL\LcnGuiMain.o:LcnGuiMain.cpp:(.text+0x1293)||undefined reference to `_imp___ZN8wxRegKey8SetValueEPKwRK8wxString'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 1 warnings ===|

I've looked exhaustively for answers and could not find any that would help. I hope I've given enough detail here. Let me know if you need more information. Thanks for your help.

Offline Deschamps

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: Linking release build without DLLs in Windows
« Reply #1 on: April 05, 2008, 07:34:40 pm »
Hello, mate.

Quote
(..) I've looked exhaustively for answers and could not find any that would help. I hope I've given enough detail here. Let me know if you need more information. Thanks for your help.

I've built static and shared versions for wxMSW 2.8.7 (both with release and debug libraries) and I'm using all of them without problems according to the apps/demos/utils I'm developing. If you plan to have different built versions for wxWidgets in the same system, i would suggest you to use some tool as wx-config. It's usage is really easy, and you could forget all those defines, library paths, and so.

You'll only need to specify the configuration ('--wxcfg' parameter) used in each build target. Another benefit you'll find using wx-config is that if you're developing also for Linux platforms, you could use almost the same C::B project without changes in most cases.

Regards.

Edit: wrong link :)

Edit again: attached is a dumb example that I use as user template for simple wxMSW applications. Its project includes the usual four targets (release/debug and static/shared). In order to compile it, you'll need wx-config accesible from your system path (mingw/bin folder is a nice place to copy this utility) and a defined WXWIN variable pointing to the root folder where you have wxMSW, e.g. ="C:\wxMSW-2.8.7" (you can define this variable inside Code::Blocks or in your system enviroment variables, as you like).


[attachment deleted by admin]
« Last Edit: April 05, 2008, 08:08:24 pm by Deschamps »
Those who were seen dancing were thought to be insane by those who could not hear the music

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Linking release build without DLLs in Windows
« Reply #2 on: April 06, 2008, 02:17:59 am »
||warning: ./wx_pch.h.gch/Debug_wx_pch_h_gch: created using different flags|
At a guess, the release build is picking up the debug precompiled header when it shouldn't be. Have you tried selecting the release target, then doing a full rebuild? (Ctrl+F11)
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

beethoven62

  • Guest
Re: Linking release build without DLLs in Windows
« Reply #3 on: April 07, 2008, 05:34:51 am »
Thanks Deschamps, the wx-config utility did the trick. I have been using it in my Linux platform because it was built in, but not in Windows. In fact, I wasn't aware that it existed for Windows.