From b91ab1724c8f459e8dad10f5c5d58d6caa9a2077 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Jul 2018 22:39:12 +0200 Subject: [PATCH] Try to better explain how to use wxWidgets from user projects Notably mention the need to add the path to the build-specific setup.h file. Also refer to CMake to help people using this build system. Closes https://github.com/wxWidgets/wxWidgets/pull/864 --- docs/msw/install.txt | 55 ++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/docs/msw/install.txt b/docs/msw/install.txt index f5093ee160..edc62025ae 100644 --- a/docs/msw/install.txt +++ b/docs/msw/install.txt @@ -27,6 +27,12 @@ Otherwise, or if you want to build a configuration of the library different from the default one, you need to build the library from sources before using it. +If you use CMake, please see + + https://docs.wxwidgets.org/trunk/overview_cmake.html + +for building wxWidgets using it. + The first step, which you may have already performed, unless you are reading this file online, is to download the source archive and uncompress it in any directory. It is strongly advised to avoid using @@ -491,21 +497,35 @@ LDFLAGS Building Applications Using wxWidgets ===================================== -NB: The makefiles and project files provided with wxWidgets samples show which - flags should be used when building applications using wxWidgets so in case - of a problem, e.g. if the instructions here are out of date, you can always - simply copy a makefile or project file from %WXWIN%\samples\minimal or some - other sample and adapt it to your application. +If you want to use CMake for building your project, please see -Independently of the compiler and make/IDE you are using you must do the -following to use wxWidgets sources under the directory $WXWIN (notice that + https://docs.wxwidgets.org/trunk/overview_cmake.html#cmake_apps + +Otherwise follow the instructions below for "manual" setup of your project. + +We suppose that wxWidgets sources are under the directory $WXWIN (notice that different tool chains refer to environment variables such as WXWIN in -different ways, e.g. MSVC users should use $(WXWIN) instead of just $WXWIN): +different ways, e.g. MSVC users should use $(WXWIN) instead of just +$WXWIN). And we will use as a shortcut for the subdirectory of +$WXWIN\lib which is composed from several parts separated by underscore: +first, a compiler-specific prefix (e.g. "vc" for MSVC, "gcc" for g++ or the +value of COMPILER_PREFIX if you set it explicitly), then optional "x64" if +building in 64 bits and finally either "lib" or "dll" depending on whether +static or dynamic wx libraries are being used. + +For example, WXWIN could be "c:\wxWidgets\3.4.5" and could be +"c:\wxWidgets\3.4.5\lib\vc_x64_lib" for 64-bit static libraries built with +MSVC. + +Here is what you need to do: * Add $WXWIN\include to the - compiler - resource compiler include paths. +* If using MSVC, prepend $WXWIN\include\msvc to the include paths too. + Otherwise, append \mswu[d] to the include paths, where "d" should + be used for debug builds only. * Define the following symbols for the preprocessor: - __WXMSW__ to ensure you use the correct wxWidgets port. - _UNICODE unless you want to use deprecated ANSI build of wxWidgets. @@ -513,8 +533,12 @@ different ways, e.g. MSVC users should use $(WXWIN) instead of just $WXWIN): - WXUSINGDLL if you are using DLL build of wxWidgets. * If using MSVC 7 only (i.e. not for later versions), also define wxUSE_RC_MANIFEST=1 and WX_CPU_X86. -* Add $WXWIN\lib\prefix_lib-or-dll to the libraries path. The prefix depends - on the compiler, by default it is "vc" for MSVC, "gcc" for g++ and so on. +* Add directory described above to the libraries path. + +When using MSVC, the libraries are linked automatically using "#pragma +comment(lib)" feature of this compiler. With all the other compilers you also +need to: + * Add the list of libraries to link with to the linker input. The exact list depends on which libraries you use and whether you built wxWidgets in monolithic or default multlib mode and basically should include all the @@ -524,8 +548,9 @@ different ways, e.g. MSVC users should use $(WXWIN) instead of just $WXWIN): (all wxWidgets applications use the base library). -Microsoft Visual C++ users can simplify the linker setup by prepending -"$(WXWIN)\include\msvc" to the include path (it must come before the -"$(WXWIN)\include" part!) and omitting the last step: the required libraries -will be linked in automatically using the "#pragma comment(lib)" feature of -this compiler. +Finally, please notice that the makefiles and project files provided with +wxWidgets samples show which flags should be used when building applications +using wxWidgets and always work, so in case of a problem, e.g. if the +instructions here are out of date, you can always simply copy a makefile or +project file from $WXWIN\samples\minimal or some other sample and adapt it to +your application.