Difference between revisions of "HowTo compile with cmake"
From AMule Project FAQ
Vollstrecker (Talk | contribs) (→= boost) |
Vollstrecker (Talk | contribs) (Added instructions for zlib.) |
||
(30 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
*An IDE that is supported by cmake, to generate code for it. | *An IDE that is supported by cmake, to generate code for it. | ||
− | *[https://www.boost.org boost] headers and system-lib -> [https:// | + | *[https://www.boost.org boost] headers and system-lib -> [https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.zip Download (1.7.0)] |
− | *[https://cmake.org cmake] - [https:// | + | *[https://cmake.org cmake] -> [https://github.com/Kitware/CMake/releases/download/v3.15.0/cmake-3.15.0-win32-x86.msi Download (3.15.0 32-Bit)] |
− | *[http://www.cryptopp.com/ Crypto++] library -> [https://www.cryptopp.com/ | + | *[http://www.cryptopp.com/ Crypto++] library -> [https://www.cryptopp.com/cryptopp820.zip Download (8.2.0)] |
*flex and bison -> [https://sourceforge.net/projects/winflexbison/files/win_flex_bison-latest.zip/download download precompiled bundle here]. | *flex and bison -> [https://sourceforge.net/projects/winflexbison/files/win_flex_bison-latest.zip/download download precompiled bundle here]. | ||
− | *[https://git-scm.org git for windows] -> [https://github.com/git-for-windows/git/releases/download/v2. | + | *[https://git-scm.org git for windows] -> [https://github.com/git-for-windows/git/releases/download/v2.22.0.windows.1/Git-2.22.0-32-bit.exe Download (2.22.0)] |
− | *libGeoIP [https://github.com/maxmind/geoip-api-c Download or git clone] | + | *libGeoIP -> [https://github.com/maxmind/geoip-api-c Download or git clone] |
− | *[[wxWidgets]] | + | *[http://www.libpng.org/pub/png/libpng.html libpng] -> [https://download.sourceforge.net/libpng/lpng1637.zip Download 1.6.37] |
− | *[http://www.zlib.org zlib] compression library [http://zlib.net/ | + | *[[wxWidgets]] -> [https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.2/wxWidgets-3.1.2.zip Version 3.1.2]) |
+ | *[http://www.zlib.org zlib] compression library -> [http://www.zlib.net/zlib-1.2.11.tar.gz Download (1.2.11)] | ||
== Unpacking the sources == | == Unpacking the sources == | ||
*Create a root folder. You can name it whatever you want. In this example it is called "aMule". | *Create a root folder. You can name it whatever you want. In this example it is called "aMule". | ||
− | *Unpack wx, cryptopp flex/bison | + | *Unpack wx, cryptopp and flex/bison into that folder. (Just to find them again. In fact it doesn't matter where put them. |
+ | *Unpack zlib, rename the folder to zlib only (without version) and place it in the same directory as you libpng sources. | ||
− | == Preparing the libraries needed == | + | == Preparing the libraries needed to build with visual studio == |
=== boost === | === boost === | ||
− | *Open | + | *Open a Visual Studio Command Prompt from your startmenu |
− | + | ||
*cd into the dir, where you extracted the source | *cd into the dir, where you extracted the source | ||
*run bootstrap | *run bootstrap | ||
− | *run | + | *run b2 install |
=== cryptopp === | === cryptopp === | ||
Line 31: | Line 32: | ||
*Select Release or Debug build. | *Select Release or Debug build. | ||
'''This is important, as cryptlib.h will be generated and compile will only work with the same config. | '''This is important, as cryptlib.h will be generated and compile will only work with the same config. | ||
− | This also means, if you've built cryptopp with Debug option, you can build aMule only with Debug enabled''' | + | This also means, if you've built cryptopp with Debug option, you can build aMule only with Debug enabled |
+ | I'll recommend anyway to always build both types''' | ||
*Right click on '''cryptlib''' goto Properties C/C++ -> Code Generation and set the Runtime-Library to /MD (/MDd for Debug) | *Right click on '''cryptlib''' goto Properties C/C++ -> Code Generation and set the Runtime-Library to /MD (/MDd for Debug) | ||
*Build the cryptlib project in the solution | *Build the cryptlib project in the solution | ||
=== libGeoIP === | === libGeoIP === | ||
− | *Open | + | *Open a Visual Studio Command Prompt from your startmenu |
− | + | ||
*cd into the dir, where you extracted the source | *cd into the dir, where you extracted the source | ||
*run nmake /f Makefile.vc | *run nmake /f Makefile.vc | ||
+ | |||
+ | === libpng === | ||
+ | *Open die vstudio project | ||
+ | *When using Visual Studio 2019 | ||
+ | **Open the properties of libpng, got to C/C++ -> All Options and change the warning-level to max /W3 on Debug and Release config | ||
+ | **Repeat'the above for zlib | ||
+ | *Build the libpng project of the solution. | ||
=== wxWidgets === | === wxWidgets === | ||
*Just open the project that suits your IDE and build the whole solution. | *Just open the project that suits your IDE and build the whole solution. | ||
− | === aMule === | + | === zlib === |
− | *Start GIT-GUI (or git-bash or anything you like) from your start-menu (or whatever your current installation has. | + | *zlib ships an useable cmake-project. |
+ | **Open the dir where you extracted the source and point your cmake-gui to that dir. Build dir can point to the same dir. | ||
+ | **Configure the project | ||
+ | **adjust the install paths to a new dir. Recommended one beside you aMule build-dir. | ||
+ | **Generate and open the project. | ||
+ | **Build the install target. | ||
+ | |||
+ | == Preparing the libraries needed to build with MinGW based systems == | ||
+ | |||
+ | === boost === | ||
+ | *Open an cmdline | ||
+ | *switch to <boostDir> | ||
+ | *Run bootstrap gcc | ||
+ | *Run .\b2 install --toolset=gcc | ||
+ | |||
+ | === cryptopp === | ||
+ | *The version from github has a CMakeLists.txt, so just open and configure it. | ||
+ | *Open the file <cryptoppDir>/config.h | ||
+ | *Compile with the tools you generated a Makefile for. | ||
+ | |||
+ | === libGeoIP === | ||
+ | *Open an editor and create a new file with this content: | ||
+ | <code>ADD_LIBRARY (libGeoIP | ||
+ | GeoIP.c | ||
+ | GeoIP_deprecated.c | ||
+ | GeoIPCity.c;regionName.c | ||
+ | timeZone.c | ||
+ | ) | ||
+ | |||
+ | TARGET_COMPILE_DEFINITIONS (libGeoIP | ||
+ | PRIVATE PACKAGE_VERSION="1.6.3" | ||
+ | )''</code> | ||
+ | *Save this file in geoipDir/LibGeoIP/ with name CMakeLists.txt | ||
+ | *Open cmake-gui, configure it | ||
+ | *Open use to compile, with anything you generated build-files for. | ||
+ | |||
+ | === libpng === | ||
+ | *Thankfully libpng comes with an CMakeLists.txt, so you can just use cmake to compile everything. | ||
+ | |||
+ | === wxWidgets === | ||
+ | *Open an cmdline | ||
+ | *switch to <wxDir>/build/msw | ||
+ | *Run mingw32-make -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 CXXFLAGS=-std=gnu++11 | ||
+ | *Run mingw32-make -f makefile.gcc UNICODE=1 SHARED=1 CXXFLAGS=-std=gnu++11 | ||
+ | |||
+ | == Preparing aMule == | ||
+ | *Start GIT-GUI (or git-bash or anything you like) from your start-menu (or whatever your current installation has). | ||
*Point the repo to https://github.com/amule-project/amule.git and clone it to whereever you want. | *Point the repo to https://github.com/amule-project/amule.git and clone it to whereever you want. | ||
*Checkout branch cmake. | *Checkout branch cmake. | ||
Line 60: | Line 114: | ||
If (and it will be the case if you didn't move anything you downloaded or compiled into system directories) not everything needed is found. | If (and it will be the case if you didn't move anything you downloaded or compiled into system directories) not everything needed is found. | ||
− | *For the libraries: Open a Texteditor, open <your-amule-folder>\cmake | + | *For the libraries: Open a Texteditor, open <your-amule-folder>\cmake\searchdirs.cmake |
+ | **Turn on advanced view in cmake-gui (I prefer to enable grouped view, too). Now you can set the dirs to search (take the opened file as hint). | ||
+ | **Uncomment the needed lines, and point it to where the stuff was created. | ||
*For the binaries (flex/bison) you can select the files directly in cmake (i.e BISON_EXECUTABLE for bison) after enabling advanced opton. | *For the binaries (flex/bison) you can select the files directly in cmake (i.e BISON_EXECUTABLE for bison) after enabling advanced opton. | ||
*Hit configure again | *Hit configure again | ||
Line 71: | Line 127: | ||
== Tested with == | == Tested with == | ||
− | *Microsoft Visual C++ 2010 (VC10) [https://www.microsoft.com/ | + | *Microsoft Visual C++ 2010 (VC10) [https://www.microsoft.com/en-us/download/details.aspx?id=23507 Download] |
− | *Microsoft Visual Studio 2012 (VC11) | + | *Microsoft Visual Studio 2012 (VC11) (official download-link is dead) |
− | *Microsoft Visual Studio 2013 (VC12) | + | *Microsoft Visual Studio 2013 (VC12) (official download-link is dead) |
+ | *Microsoft Visual Studio 2015 (VC14) (official download-link is dead) |
Latest revision as of 12:34, 6 March 2020
Contents
Requirements for compiling aMule for Windows using cmake
You will need the following packages:
- An IDE that is supported by cmake, to generate code for it.
- boost headers and system-lib -> Download (1.7.0)
- cmake -> Download (3.15.0 32-Bit)
- Crypto++ library -> Download (8.2.0)
- flex and bison -> download precompiled bundle here.
- git for windows -> Download (2.22.0)
- libGeoIP -> Download or git clone
- libpng -> Download 1.6.37
- wxWidgets -> Version 3.1.2)
- zlib compression library -> Download (1.2.11)
Unpacking the sources
- Create a root folder. You can name it whatever you want. In this example it is called "aMule".
- Unpack wx, cryptopp and flex/bison into that folder. (Just to find them again. In fact it doesn't matter where put them.
- Unpack zlib, rename the folder to zlib only (without version) and place it in the same directory as you libpng sources.
Preparing the libraries needed to build with visual studio
boost
- Open a Visual Studio Command Prompt from your startmenu
- cd into the dir, where you extracted the source
- run bootstrap
- run b2 install
cryptopp
- If you use VisualStudio, open one of the projects you find in the source-dir. For others instructions will go here, when tested.
- Select Release or Debug build.
This is important, as cryptlib.h will be generated and compile will only work with the same config. This also means, if you've built cryptopp with Debug option, you can build aMule only with Debug enabled I'll recommend anyway to always build both types
- Right click on cryptlib goto Properties C/C++ -> Code Generation and set the Runtime-Library to /MD (/MDd for Debug)
- Build the cryptlib project in the solution
libGeoIP
- Open a Visual Studio Command Prompt from your startmenu
- cd into the dir, where you extracted the source
- run nmake /f Makefile.vc
libpng
- Open die vstudio project
- When using Visual Studio 2019
- Open the properties of libpng, got to C/C++ -> All Options and change the warning-level to max /W3 on Debug and Release config
- Repeat'the above for zlib
- Build the libpng project of the solution.
wxWidgets
- Just open the project that suits your IDE and build the whole solution.
zlib
- zlib ships an useable cmake-project.
- Open the dir where you extracted the source and point your cmake-gui to that dir. Build dir can point to the same dir.
- Configure the project
- adjust the install paths to a new dir. Recommended one beside you aMule build-dir.
- Generate and open the project.
- Build the install target.
Preparing the libraries needed to build with MinGW based systems
boost
- Open an cmdline
- switch to <boostDir>
- Run bootstrap gcc
- Run .\b2 install --toolset=gcc
cryptopp
- The version from github has a CMakeLists.txt, so just open and configure it.
- Open the file <cryptoppDir>/config.h
- Compile with the tools you generated a Makefile for.
libGeoIP
- Open an editor and create a new file with this content:
ADD_LIBRARY (libGeoIP
GeoIP.c GeoIP_deprecated.c GeoIPCity.c;regionName.c timeZone.c
)
TARGET_COMPILE_DEFINITIONS (libGeoIP
PRIVATE PACKAGE_VERSION="1.6.3"
)
- Save this file in geoipDir/LibGeoIP/ with name CMakeLists.txt
- Open cmake-gui, configure it
- Open use to compile, with anything you generated build-files for.
libpng
- Thankfully libpng comes with an CMakeLists.txt, so you can just use cmake to compile everything.
wxWidgets
- Open an cmdline
- switch to <wxDir>/build/msw
- Run mingw32-make -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 CXXFLAGS=-std=gnu++11
- Run mingw32-make -f makefile.gcc UNICODE=1 SHARED=1 CXXFLAGS=-std=gnu++11
Preparing aMule
- Start GIT-GUI (or git-bash or anything you like) from your start-menu (or whatever your current installation has).
- Point the repo to https://github.com/amule-project/amule.git and clone it to whereever you want.
- Checkout branch cmake.
Creating the solution
- Open cmake-gui
- Point the source-code directory to where you cloned the repo
- Point the build directory to wherever you want
- Hit configure and select the generator for the IDE you want to use and click finish.
- Now you can select all the options you want, and hit configure again.
- Hit generate
Setting the paths needed
If (and it will be the case if you didn't move anything you downloaded or compiled into system directories) not everything needed is found.
- For the libraries: Open a Texteditor, open <your-amule-folder>\cmake\searchdirs.cmake
- Turn on advanced view in cmake-gui (I prefer to enable grouped view, too). Now you can set the dirs to search (take the opened file as hint).
- Uncomment the needed lines, and point it to where the stuff was created.
- For the binaries (flex/bison) you can select the files directly in cmake (i.e BISON_EXECUTABLE for bison) after enabling advanced opton.
- Hit configure again
- Hit generate
Compiling
- Open the created project files in the build directory you've set.
- Choose Debug/Release etc. like you selected for cryptopp before.
- Start compilation.
Tested with
- Microsoft Visual C++ 2010 (VC10) Download
- Microsoft Visual Studio 2012 (VC11) (official download-link is dead)
- Microsoft Visual Studio 2013 (VC12) (official download-link is dead)
- Microsoft Visual Studio 2015 (VC14) (official download-link is dead)