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
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Aug 10, 2019 11:55 am

How to switch between static and dynamic link?

Post by vjedlicka » Sat Aug 10, 2019 12:04 pm

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: 2057
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to switch between static and dynamic link?

Post by PB » Sat Aug 10, 2019 1:03 pm

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
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Aug 10, 2019 11:55 am

Re: How to switch between static and dynamic link?

Post by vjedlicka » Tue Aug 13, 2019 4:03 pm

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: 2057
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to switch between static and dynamic link?

Post by PB » Tue Aug 13, 2019 6:27 pm

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: 3454
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to switch between static and dynamic link?

Post by ONEEYEMAN » Tue Aug 13, 2019 6:31 pm

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
In need of some credit
In need of some credit
Posts: 3
Joined: Sat Aug 10, 2019 11:55 am

Re: How to switch between static and dynamic link?

Post by vjedlicka » Tue Aug 13, 2019 8:00 pm

Thank you
Vaclav

Post Reply