compiling notepad2 under Visual Studio 2010
By Jeroen on Monday 31 August 2009, 23:27 - Permalink
Notepad2 is an excellent lightweight text editor, intended as a replacement for Notepad. I like to call it 'notepad on steroids': a simple text editor, but still containing most features you've come to expect using more advanced (and often bloated) editors. The tool written by Florian Balmer and the best part is that it's open source!
Now Florian is using Visual Studio 6.0 for developing his app, which certainly does the job, but I didn't really feel like installing 6.0 alongside Visual Studio 2010 Beta 1. Turns out it's relatively easy to get it compiled under 2010 (will probably also work in Visual Studio 2008 and 2005, but I didn't try myself).
First of all, download the Notepad2 source code. I started with v4.0.22.
You also need to download the corresponding version of the scintilla source code. Put this in in a subfolder called 'scintilla' in the same folder as the Notepad2 solution file (notepad2.sln). Notepad2 4.0.22 is based on scintilla 1.79.
Now open the Notepad2.sln solution in Visual Studio 2010. Next-Next-Finish to upgrade the .sln and .vcproj files. The upgrade wizzard will create a file called notepad2.vcxproj, and notepad2.vcxproj.filters, making the .vcproj file obsolete.
Finally, you will notice that the solution does not build yet. You need to the following edits. Start with applying the instructions from Flo's readme: disable the definition of LINK_LEXER in scintilla\keywords.cxx:
#define LINK_LEXER(lexer) extern LexerModule lexer; ...
must be replaced with:
#define LINK_LEXER(lexer) void(0)
Now I got a compiler error complaining that LPSHELLICON is not defined. In the file dlapi.h, I added the following:
#ifndef LPSHELLICON typedef struct IShellIcon IShellIcon, *LPSHELLICON; #endif
Finally, I remained with a link error, something about the manifest. This can be resolved by commenting out the line starting with 'IDR_RT_MANIFEST' in the file Notepad2.rc.
EDIT - Disclaimer: Florian notified me that this may have unwanted side effects. Do this at your own risk. Your PC may blow into pieces. You have been warned (but it Works On My Machine :-)). I may look into the details of it in a future post.
Anyway, that's it! Everything should compile and run now.