-
Notifications
You must be signed in to change notification settings - Fork 212
Build Notepad4
Open build/VS2017/Notepad4.sln
, select appreciate project, configuration and platform to build. The build output directory is build/bin/${Configuration}/${Platform}
.
Please install "Windows XP support for C++" or change Platform Toolset in Project Property Pages to other non-XP one if you want to build Win32 program.
For Visual Studio 2017, 2019 or 2022, VS_PATH
environment variable may need manually set to the installation path (e.g.: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
).
Batch File | Usage |
---|---|
build_x64.bat | build x64 release |
build_win32.bat | build Win32 release |
build_arm.bat | build ARM32 release |
build_arm64.bat | build ARM64 release |
build_avx2.bat | build x64 release with AVX2 instructions |
build.bat | build.bat [Action] [Platform] [Configuration] |
- | - |
Action | Help, Build (the default), Clean, Rebuild |
Platform | all (the default), x86, Win32, x64, AVX2, ARM64, ARM, NoARM (all except 32-bit ARM), No32bit (x64, AVX2 and ARM64) |
Configuration | all (Release and Debug), Release (the default), Debug, LLVMDebug, LLVMRelease |
Install LLVM (7.0.0 and later) from https://github.com/llvm/llvm-project/releases or https://releases.llvm.org/ and install LLVM for Visual Studio from https://github.com/zufuliu/llvm-utils. Then select LLVMDebug
, LLVMRelease
, AVX2LLVMDebug
or AVX2LLVMRelease
build configuration to build. The build output directory is build/bin/LLVM$(Configuration)/$(Platform)
.
If you already installed "LLVM Compiler Toolchain" from Visual Studio Marketplace, you can change "Platform Toolset" to LLVM
to use this extension.
If you already installed "C++ Clang-cl for v14* build tools (x64/x86)" (Visual Studio 2019 v142 or 2022 v143), you can change "Platform Toolset" to LLVM (clang-cl)
to use it. See the document at https://docs.microsoft.com/en-us/cpp/build/clang-support-msbuild.
Right-click "Solution 'Notepad4'" in Solution Explorer or click Visual Studio's Project menu, then click Intel Compiler -> Use Intel C++.
Suggest using latest mingw-w64 GCC (7.1.0 or later) x86_64-posix-seh
for x64 build and i686-posix-dwarf
for Win32 build. They can be installed inside MSYS2 using pacman:
pacman -Syuu
# x64, AVX2 build
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-tools-git
# x64, AVX2 build with Clang
pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-lld
# Win32 build
pacman -S mingw-w64-i686-gcc mingw-w64-i686-make mingw-w64-i686-tools-git
# Win32 build with Clang
pacman -S mingw-w64-i686-clang mingw-w64-i686-lld
You can also use other ready for use standalone GCC/Clang packages, such as https://github.com/mstorsjo/llvm-mingw, https://github.com/brechtsanders/winlibs_mingw, https://sourceforge.net/projects/mingw-w64/files/, https://jmeubank.github.io/tdm-gcc/, etc.
llvm-mingw is required to build for ARM64 and ARM. Old mingw-w64 GCC (before v6.0.0, released on 2018-09-17) will cause SIGSEGV when you try to enable bidirectional (see issue #16).
Following table are options (all are optional) for Makefile (in build\mingw\
folder). The build output directory is build\bin\Debug_<ARCH>
, build\bin\Release_<ARCH>
(or build\bin\ClangDebug_<ARCH>
, build\bin\ClangRelease_<ARCH>
when Clang is used).
Option | Description |
---|---|
DEBUG | Debug build, default is release build |
TRIPLET | Cross compiling target triplet (x86_64-w64-mingw32, i686-w64-mingw32, aarch64-w64-mingw32, armv7-w64-mingw32, etc.) |
ARCH | Cross compiling target architecture (x64, AVX2, Win32, ARM64 and ARM), default auto detection |
CLANG | Use clang and clang++ instead of gcc and g++ |
LLD | Use lld as the linker |
LTO | Enable LTO for release build |
WIN7 | Set x64 or Win32 build to target Windows 7 instead of Windows XP |
Download and install CodeLite from https://codelite.org/. Add GCC (and/or Clang) to build settings (Menu -> Settings -> Build Settings
).
Open build/CodeLite/Notepad4.workspace
, in Workspace panel, select appreciate project and configuration to build. The build output directory is build/bin/$(Configuration)_$(Platform)
or build/CodeLite/build_$(Configuration)_$(Platform)/bin
, depends on CodeLite version. You can change project settings by right-click project folder in Workspace panel, then click "Settings...". More document for CodeLite can be found at https://wiki.codelite.org/.
Note: C++ language standard is not specified in C++ Compiler Options
, if you GCC's default C++ standard is not gnu++17 or later, please add language standard (such as -std=gnu++17
for C++) to compiler options in Project Settings
.
Currently compiler supporting for C++17 is required.
Some functions (encoding validating, line endings detection, etc.) in Notepad4 are optimized for SSE2 and AVX2, they can be enabled by editing scintilla\include\VectorISA.h
, and set NP2_USE_SSE2
or NP2_USE_AVX2
to 1.
The AVX2 build works for Windows 7 SP1 (or Windows Server 2008 R2 SP1) and above (64-bit only), requires target CPU additional support for POPCNT (included in SSE4.2), e.g. CPU sold since 2013, such as Intel Core i3, i5, i7, i9 or AMD Excavator, Zen, and more.
Clang and GCC need using -mavx2 -mpopcnt
(see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html) compiler options to enable full AVX2 build. -mbmi
can also be used to get TZCNT instead of _BitScanForward().
MSVC need to enable /arch:AVX2
(in project Property Pages, C/C++ -> Code Generation -> Enable Enhanced Instruction Set) when build for AVX2.
SSE2 is introduced since Pentium 4 in 2000, SSE is introduced since Pentium III in 1999. If you need to use Notepad4 and matepath on system with old CPUs that do not support them, you need to build Notepad4 and matepath manually by set NP2_USE_SSE2
to 0 and change project files before build.
Open project Property Pages for Release configuration for Win32 platform, click "C/C++", then "Code Generation", Change "Enable Enhanced Instruction Set" to "Not Set" or "Streaming SIMD Extensions (/arch:SSE)".
Or you can open Notepad4.vcxproj and matepath.vcxproj using some text editor, remove the line <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
directly from the project file.
Open the Project Settings dialog for Notepad4 and matepath, Select "Release_Win32", click "Compiler", In "C++ Compiler Options" and "C Compiler Options" fields, remove -msse2;-mfpmath=sse;
.
Or you can open Notepad4.project and matepath.project using some text editor, remove -msse2;-mfpmath=sse;
directly from the project file.
Code before Cleanup LoadLibrary() and GetModuleHandle() for Windows 2000 support build for Window 2000 (may require some tweaks). Legacy code for Windows 2000 is completely removed by commit 626becd.
Tweak current code for Windows 2000 need more work and test, though used Windows XP and above only function is very small.
Other broken changes for Windows 2000:
- uxtheme.dll (not available on Windows 2000) is directly linked instead of dynamic loaded at runtime since commit c951b0b.
- GdiAlphaBlend() is used other than AlphaBlend(), some old compiler (such as originally MinGW, see https://sourceforge.net/p/scintilla/bugs/1923/) may not have this function in SDK headers.