Compiling Notepad++

From Notepad++ Wiki
Jump to: navigation, search
How To Compile Notepad++ From Source


There should be several ways to generate Notepad++ binaries.

The official releases of Notepad++ are generated using Visual Studio 2005.


Using Visual C++ 2008 Express Edition

Setup

  1. Download and install Visual C++ 2008 Express Edition. There are 3 components; it is only necessary to install the first (IDE) and not the other two (MSDN and Database).
  2. Run Visual C++ 2008 Express Edition once to set up environment (it is mentioned somewhere in the SDK documentation to do this).
  3. Download and install the Platform SDK whose exact name is "Windows Server 2008".
  4. Start Visual C++ 2008 Express Edition again, go to Tools -> Options -> Projects and Solutions -> VC++ Directories, and do these three steps (using the 'arrow up' button):
    1. In Show directories for -> Executable Files, move $(WindowsSdkDir)\bin up so its above $(VCInstallDir)\bin.
    2. In Show directories for -> Include Files, move $(WindowsSdkDir)\include up so its above $(VCInstallDir)\include.
    3. In Show directories for -> Library Files, move $(WindowsSdkDir)\lib up so its above $(VCInstallDir)\lib.
  5. Download the Notepad++ source code. There are several ways to do this. Select one of the following methods:
    • Either check out the source code directly from Subversion; the repository URL is svn://svn.tuxfamily.org/svnroot/notepadplus/repository. You can use TortoiseSVN or any other SVN client to check it out. Check it out into your My Documents\Visual Studio 2008\Projects\ folder.
    • Or download a GNU tarball of the latest source code from the Subversion web interface. Unpack the tarball to a new folder in your My Documents\Visual Studio 2008\Projects\ folder.
    • Or download the zip file "npp.6.6.6.src.7z" in the folder "npp 6.6.6 src" that should exist in the "notepad++ releases source" folder at Sourceforge. At the time of writing this, though, the zip file of the latest version was not available. But if it is, download it and unzip it as a new folder in your My Documents\Visual Studio 2008\Projects\ folder.
  6. Download the latest Boost library from http://www.boost.org/users/download/ and unzip in a hard disk of your choice. The archive only contains one folder with a lush sbtree under it.

Build Notepad++ v6.6.6 (win32, Debug)

  1. Within VC++ IDE select Tools -> Visual Studio 2008 command prompt
  2. Change current directory to your\sorce_code\directory\scintilla\boostregex. Don't forget to surround this path with double quotes if it contains spaces.
  3. Now run
BuildBoost.bat --toolset msvc-9.0 your\boost\install\folder

The folder should have the "bin v2" subfolder right below it.

  1. If all goes well, the console informs you of the next two steps:
  2. Change directory to ..\win32
  3. From there, run
nmake -f scintilla.mak"
  1. At this point you have a SciLexer.dll ready in ..\bin, with full regula expression support. You can safely ignore the harmless warnings about unused local functions. Copy it where your executable should be created - it needs it.
  2. Open My Documents\Visual Studio 2008\Projects\npp.6.6.6.src\PowerEditor\visual.net\notepadPlus.vcproj.
    • IMPORTANT: do NOT open notepadPlus.7.0.vcproj, it doesn't build (linker error).
  3. Allow the project upgrade wizard to run with defaults
  4. Select Project -> Build Order and confirm that SciLexer is before notepadPlus in the build order
  5. Build the solution. When prompted save your vc2008 project somewhere (eg My Documents\Visual Studio 2008\Projects\npp.6.6.6.src\PowerEditor\visual.net\SciLexer vc2008). The IDE should build Scintilla first, followed by Notepad++. There should be no errors besides the following:
  6. The result of the Notepad++ build is My Documents\Visual Studio 2008\Projects\npp.6.6.6.src\PowerEditor\visual.net\Debug\Notepad++.exe. You must have copied SciLexer.dll there. Otherwise, Notepad++ might try an older dll with unpredictable results.

How to build a sample plugin (NppPluginDemo)

This is how to build a sample plugin. Note that building a plugin is not necessary if you just want to compile Notepad++ itself.

  1. Download and unzip the Notepad++ Plugin Demo source code into the folder My Documents\Visual Studio 2008\Projects\NppPluginDemo.
  2. Within Visual Studio 2008 select File -> Open -> Project/Solution and open the project My Documents\Visual Studio 2008\Projects\NppPluginDemo\NppPluginDemo.vcproj; allow the project upgrade wizard to run with defaults.
  3. Save your Visual Studio 2008 project under a new name.
  4. Build the solution.
  5. The result of the plugin build is found in My Documents\Visual Studio 2008\Projects\notepad++\PowerEditor\bin\plugins.
  6. IMPORTANT: Try the Release builds to see if they also work.

A recommended development environment

The following has been posted on Open Discussion Forum and results from interactive setup through the official Notepad++ IRC channel.

  1. Use Visual C++ 2008 EE
  2. Checkout the latest trunk
  3. Open the PowerEditor visual.net notepadPlus.vcproj file
  4. Add dependency to PowerEditor (it should depend on SciLexer).


Using Visual C++ 2010 Express Edition

See the article How to build Notepad++ with Visual C++ 2010 Express?.


Fixing or enhancing Notepad++

So you modified the code, and that has fixed a bug, enhanced or added some functionality?

Then the usual rules about open source code apply:

  • thoroughly test that you don't cause regressions, ie break something that previously worked. If at all possible, ask non programmers to test. They are pretty good at hitting gaping faults we don't see.
  • Incorrectly commented code is bad code. You have no idea of whoever will maintain your code, neither when nor why. No one else does anyway.

Brilliant and perfect? Then you can contact the main developer about it. Make a patch to apply your mods to the latest revision on SVN, and submit it at https://sourceforge.net/tracker/?group_id=95717&atid=612384

You may want to read this thread: How do I join the development team?.

And the story ends here, they lived happy and had lots of lines of code.