Difference between revisions of "HowTo compile with Visual Studio"

From AMule Project FAQ
Jump to: navigation, search
(fixed option for release build)
(more updates)
Line 3: Line 3:
 
You will need the following packages:
 
You will need the following packages:
  
*Microsoft [http://msdn.microsoft.com/en-us/vstudio/default.aspx Visual Studio] 2008 (called "VS"), the free Express Edition (called "VSE") is supported for aMule SVN only
+
*Microsoft [http://msdn.microsoft.com/en-us/vstudio/default.aspx Visual Studio] 2008 (called "VS"), the free Express Edition (called "VSE") is supported for aMule SVN and 2.2.3 only
 
*Windows port of [[wxWidgets]] library (known as wxMSW) -> [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.9.zip Download (2.8.9)] (There is a bug in 2.8.9 which causes black background for toolbar images with 16bit desktop colour depth. In that case use [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8.zip 2.8.8] or [http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH 2.8 SVN]. )
 
*Windows port of [[wxWidgets]] library (known as wxMSW) -> [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.9.zip Download (2.8.9)] (There is a bug in 2.8.9 which causes black background for toolbar images with 16bit desktop colour depth. In that case use [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.8.zip 2.8.8] or [http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH 2.8 SVN]. )
 
* [http://www.cryptopp.com/ Crypto++] library -> [http://prdownloads.sourceforge.net/cryptopp/cryptopp552.zip Download(5.5.2)]
 
* [http://www.cryptopp.com/ Crypto++] library -> [http://prdownloads.sourceforge.net/cryptopp/cryptopp552.zip Download(5.5.2)]
Line 26: Line 26:
  
 
== Selecting the solution ==
 
== Selecting the solution ==
#aMule 2.2.2 ships with only one solution "aMule-MSVC.sln" which works only with the commercial edition of VS. This solution includes everything - aMule, tools, external libs, organized in folders (which VSE does not allow).
+
#aMule 2.2.2 ships with only one solution "aMule-MSVC.sln" which works only with the commercial edition of VS. This solution includes everything - aMule, tools, external libs, organized in folders (which VSE does not allow). Usage of this solution is ''not recommended'' for newer versions of aMule.
#In aMule SVN there are two additional solutions: "aMule-MSVCE-ExtLibs.sln" builds wxWidgets and cryptopp into a single big lib "libext.lib". "aMule-MSVCE.sln" builds aMule (including aMule's internal libs) and aMule's tools. That way the (now flat) aMule solution is not cluttered with all the wxWidgets libs, and a ''Clean Solution'' won't clean the wxWidgets build (which usually is not the intention). These solutions can be used with the commercial VS edition too.
+
#In aMule SVN and aMule 2.2.3 there are two additional solutions: "aMule-MSVCE-ExtLibs.sln" builds wxWidgets and cryptopp into a single big lib "libext.lib". "aMule-MSVCE.sln" builds aMule (including aMule's internal libs) and aMule's tools. That way the (now flat) aMule solution is not cluttered with all the wxWidgets libs, and a ''Clean Solution'' won't clean the wxWidgets build (which usually is not the intention). These solutions can be used with the commercial VS edition too.
  
 
== Compiling the external libraries for 1) ==
 
== Compiling the external libraries for 1) ==
Line 51: Line 51:
  
 
If you get errors:
 
If you get errors:
 
=== error building libGeoIP ===
 
Ignore it, unload the libGeoIP project, or enable GeoIP (see below)
 
  
 
=== error in Scanner.cpp ===
 
=== error in Scanner.cpp ===
Line 89: Line 86:
  
 
Download the free [http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.4.tar.gz GeoIP C library 1.4.4] (later versions don't work!).
 
Download the free [http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.4.tar.gz GeoIP C library 1.4.4] (later versions don't work!).
From the folder libGeoIP take "GeoIP.h" and "GeoIP.c" and put them into "MSVC Solution\libs\libGeoIP".
+
From the folder libGeoIP take "GeoIP.h" and "GeoIP.c" and put them into "MSVC Solution\libs\libGeoIP" (replacing the dummy files that may be there).
 
Apply "GeoIP.c.patch" to "GeoIP.c" . If you don't have a patch tool, you can easily apply it by hand.  
 
Apply "GeoIP.c.patch" to "GeoIP.c" . If you don't have a patch tool, you can easily apply it by hand.  
 
Just add the ''#defines'' to the beginning of the file and remove the 5 lines starting with ''#ifdef WIN32''
 
Just add the ''#defines'' to the beginning of the file and remove the 5 lines starting with ''#ifdef WIN32''
 
at line 524.
 
at line 524.
 
Copy CountryFlags.h from "MSVC Solution\libs\libGeoIP" to "src/pixmaps/flags_xpm".
 
 
In aMule's project settings ''C/C++/Preprocessor/Preprocessor Definitions'' add '';ENABLE_IP2COUNTRY''
 
 
In the solution explorer right-click on aMule, select ''Project dependencies'' and check ''libGeoIP''.
 
  
 
Rebuild aMule. That's it. :-)
 
Rebuild aMule. That's it. :-)
  
The free [http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz GeoIP country database] will be downloaded automatically on startup.
+
The free [http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz GeoIP country database] will be downloaded automatically on startup.

Revision as of 09:01, 26 November 2008

Requirements for compiling aMule for Windows using Visual Studio

You will need the following packages:

Also, 1100MB free space on your hard disk (around 40MB to download the above packages and the rest for temporary compilation files and installations. The amount of space needed will largely depend on the configuration flags you use).

As a reference, the whole compilation process will take around 20 min on a medium-high resourced computer.

Unpacking the sources

  • Create a root folder. You can name it whatever you want. In this example it is called "aMule".
  • Unpack wxMSW to "aMule\wxWidgets" (no intermediate subfolder).
  • Unpack cryptopp to "aMule\cryptopp" (no intermediate subfolder).
  • Unpack aMule to "aMule\trunk" (no intermediate subfolder). This folder can be named as you like, the 2 library folders must have exact the names from above, or the project won't load.

Preparing the library projects

  • Open "aMule\wxWidgets\build\msw\wx.dsw" in VS. It asks, if it should convert the project. Answer "Yes to all".
  • Close VS, saving the changes.

Selecting the solution

  1. aMule 2.2.2 ships with only one solution "aMule-MSVC.sln" which works only with the commercial edition of VS. This solution includes everything - aMule, tools, external libs, organized in folders (which VSE does not allow). Usage of this solution is not recommended for newer versions of aMule.
  2. In aMule SVN and aMule 2.2.3 there are two additional solutions: "aMule-MSVCE-ExtLibs.sln" builds wxWidgets and cryptopp into a single big lib "libext.lib". "aMule-MSVCE.sln" builds aMule (including aMule's internal libs) and aMule's tools. That way the (now flat) aMule solution is not cluttered with all the wxWidgets libs, and a Clean Solution won't clean the wxWidgets build (which usually is not the intention). These solutions can be used with the commercial VS edition too.

Compiling the external libraries for 1)

  • Open the aMule solution "aMule\trunk\MSVC Solution\aMule-MSVC.sln" in VS (for aMule 2.2.2 VS will again ask to convert it).
  • In the toolbar set the Solution Configuration to Debug or Release (whatever you prefer) and the Solution Platform to Win32.
  • In the solution explorer open properties of external libraries/cryptlib.
  • In Configuration Properties/C-C++/Code Generation change Runtime Library to Multithreaded Debug DLL (/MDd) for the debug build or to Multithreaded DLL (/MD) for the release build.
  • If you aren't interested in Unit Tests (or don't know what it's about) remove the UnitTests tree from the solution.
  • Right-click on external libraries and select build.

Compiling the external libraries for 2)

  • Open the aMule solution "aMule\trunk\MSVC Solution\aMule-MSVCE-ExtLibs.sln" in VS.
  • In the toolbar set the Solution Configuration to Debug or Release (whatever you prefer) and the Solution Platform to Win32.
  • In the solution explorer open properties of cryptlib.
  • In Configuration Properties/C-C++/Code Generation change Runtime Library to Multithreaded Debug DLL (/MDd) for the debug build or to Multithreaded (/MT) for the release build.
  • Hit F7.
  • If everything was fine, load "aMule\trunk\MSVC Solution\aMule-MSVCE.sln" to continue.

Compiling aMule

Just hit F7 and lean back.

If you get errors:

error in Scanner.cpp

change

b->yy_is_interactive = 0;
// b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;

'GetTickCount64' : redefinition

This happens on Vista with VS 2008. To fix it, open "GetTickCount.h" and insert

#define GetTickCount64 GetTickCount_64
uint64 GetTickCount64();

error accessing something.pdb

Sometimes VS stumbles over it's own feet. Just delete the offending pdb and try again.

Running

To run aMule from VS, right-click on Monolithic build/aMule and Set as StartUp project. Then hit F5.

To run aMule on a machine with no VS installed you have to install the Visual Studio Runtime.

aMule's configuration will be stored in your document folder in "AppData\Roaming\aMule" (under Vista).

Building aMule with GeoIP support

The MaxMind GeoIP library can detect the country an IP adress comes from. aMule uses this information to display a little country flag for each source or ed2k server. Since this is an external library it is disabled by default. This is how to enable it (only available in the SVN version):

Download the free GeoIP C library 1.4.4 (later versions don't work!). From the folder libGeoIP take "GeoIP.h" and "GeoIP.c" and put them into "MSVC Solution\libs\libGeoIP" (replacing the dummy files that may be there). Apply "GeoIP.c.patch" to "GeoIP.c" . If you don't have a patch tool, you can easily apply it by hand. Just add the #defines to the beginning of the file and remove the 5 lines starting with #ifdef WIN32 at line 524.

Rebuild aMule. That's it. :-)

The free GeoIP country database will be downloaded automatically on startup.