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
This commit is contained in:
Vadim Zeitlin 2018-07-29 22:39:12 +02:00
parent 5ddeeee825
commit b91ab1724c

View File

@ -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 different from the default one, you need to build the library from
sources before using it. 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 The first step, which you may have already performed, unless you are
reading this file online, is to download the source archive and reading this file online, is to download the source archive and
uncompress it in any directory. It is strongly advised to avoid using uncompress it in any directory. It is strongly advised to avoid using
@ -491,21 +497,35 @@ LDFLAGS
Building Applications Using wxWidgets Building Applications Using wxWidgets
===================================== =====================================
NB: The makefiles and project files provided with wxWidgets samples show which If you want to use CMake for building your project, please see
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.
Independently of the compiler and make/IDE you are using you must do the https://docs.wxwidgets.org/trunk/overview_cmake.html#cmake_apps
following to use wxWidgets sources under the directory $WXWIN (notice that
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 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 <wx-lib-dir> 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 <wx-lib-dir> 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 * Add $WXWIN\include to the
- compiler - compiler
- resource compiler - resource compiler
include paths. include paths.
* If using MSVC, prepend $WXWIN\include\msvc to the include paths too.
Otherwise, append <wx-lib-dir>\mswu[d] to the include paths, where "d" should
be used for debug builds only.
* Define the following symbols for the preprocessor: * Define the following symbols for the preprocessor:
- __WXMSW__ to ensure you use the correct wxWidgets port. - __WXMSW__ to ensure you use the correct wxWidgets port.
- _UNICODE unless you want to use deprecated ANSI build of wxWidgets. - _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. - WXUSINGDLL if you are using DLL build of wxWidgets.
* If using MSVC 7 only (i.e. not for later versions), also define * If using MSVC 7 only (i.e. not for later versions), also define
wxUSE_RC_MANIFEST=1 and WX_CPU_X86. wxUSE_RC_MANIFEST=1 and WX_CPU_X86.
* Add $WXWIN\lib\prefix_lib-or-dll to the libraries path. The prefix depends * Add <wx-lib-dir> directory described above to the libraries path.
on the compiler, by default it is "vc" for MSVC, "gcc" for g++ and so on.
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 * 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 depends on which libraries you use and whether you built wxWidgets in
monolithic or default multlib mode and basically should include all the 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). (all wxWidgets applications use the base library).
Microsoft Visual C++ users can simplify the linker setup by prepending Finally, please notice that the makefiles and project files provided with
"$(WXWIN)\include\msvc" to the include path (it must come before the wxWidgets samples show which flags should be used when building applications
"$(WXWIN)\include" part!) and omitting the last step: the required libraries using wxWidgets and always work, so in case of a problem, e.g. if the
will be linked in automatically using the "#pragma comment(lib)" feature of instructions here are out of date, you can always simply copy a makefile or
this compiler. project file from $WXWIN\samples\minimal or some other sample and adapt it to
your application.