How to switch between static and dynamic link? 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
vjedlicka
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Aug 10, 2019 11:55 am

How to switch between static and dynamic link?

Post by vjedlicka »

On Windows, using VS 2017, how do I switch between static and dynamic linking of my app?
Thanks!
Vaclav
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to switch between static and dynamic link?

Post by PB »

It depends on which configuration you are switching from/to.

The basic differences are just two:
  1. If you are using the dynamic build, WXUSINGDLL must be defined in your application project in C/C++ / Preprocessor / Preprocessor Definitions.
  2. The dynamic libraries are in $(WXWIN)/lib/vc_dll while the static ones are in $(WXWIN)/lib/vc_lib. You need to change the directories accordingly in Linker / General / Additional Library Directories. If you do not use MSVC autolinking (via including $(WXWIN)\include\msvc) you also need to changer the configuration specific include folder listed as the first in C/C++ / General / Additional Include Directories, which would be e.g. $(WXWIN)\lib\vc_dll\mswud for the dynamic debug build.
Obviously, if you are using the dynamic build, all the necessary DLLs must be available to the executable at the run time, i.e., generally be in the same folder as the program. And also obviously, you must have built wxWidgets in the required build.
vjedlicka
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Aug 10, 2019 11:55 am

Re: How to switch between static and dynamic link?

Post by vjedlicka »

ok, so the samples provided with wxWidgets are pre-configured for static build right?
(the hey the vc.lib in Linker/General/Additional...)
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to switch between static and dynamic link?

Post by PB »

wxWidgets MSVC solutions contain multiple configurations. Configurations named Debug and Release are static; configurations named DLL Debug and DLL Release use DLLs.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7460
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to switch between static and dynamic link?

Post by ONEEYEMAN »

Hi,
By default MSVC solution files will build statically linked wxWidgets libraries and produces statically linked samples.
However you can change it for the samples, if you did build the library as DLL Debug/Release.

Thank you.
vjedlicka
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Aug 10, 2019 11:55 am

Re: How to switch between static and dynamic link?

Post by vjedlicka »

Thank you
Vaclav
Post Reply