-
Notifications
You must be signed in to change notification settings - Fork 6
Install and use nana with mingw step by step
--> Please read: Troubleshooting-MinGW
With tdm-gcc.tdragon
Make sure you have the following already installed:
- git (http://git-scm.com/downloads)
- cmake (http://www.cmake.org/download/)
- mingw (i'm using this distro: http://tdm-gcc.tdragon.net/)
- an IDE or code editor of your choice
- go to your mingw folder and start "
open_distro_window.bat
". A Terminal window should occure. - go to the folder you want nana inserted to
- type "git clone https://github.com/cnjinhao/nana.git"
- go into nana's new folder ("cd nana")
- download the current hotfix branch via "
git checkout -t origin/hotfix-1.3
" (optional step) - start cmake (gui version)
- chose where the source code is (its the newly created
nana
folder: git created it for you) - chose a folder where you want the compilat at (button "browse build")
- click "generate"
- as of now, on my machines I need to reload the cache files, do this via "Menu-->File-->Reload Cache"
- In the Main Area, go to the NANA entry and uncheck "NANA_ENABLE_PNG" and "NANA_LIBPNG" as needed. Select where you want nana to be installed.
- click generate
- close cmake
- in the terminal window (opened with step 1) go to the folder you have chosen for the build folder
- type
"make"
to create the library - type
"make install"
to create in the directory you selected to install nana (by defaultCMAKE_INSTALL_PREFIX
) two directories:lib
with the compiled library, andinclude
with a copy of the nana headers
after ~2mins of compilation you should have gotten a debug build of nana without errors.
if you want to have a release build (e.g. for shorter linking times when building your own programms) opene cmake-gui again and goto "CMAKE-->CMAKE_BUILD_TYPE" and set it to "Release". after this, build again (maybe change the build dir aswell so the old debug build won't get overwritten)
Surpisingly, this was very easy done. just download nana like in the gui version step 1 - 5.
- create a new dir, where you want the library (as we are makeing an "out of source build") placed.
- type "cmake -G "MinGW Makefiles"" (on my pc its
cmake m:\nana -G "MinGW Makefiles"
) from that directory - cmake will now create your makefiles for you
- type "make", to start the compilation
- type "make install" to make a clean copy of the compiled nana.
again, after ~2 mins the compilation should be finnished.
if cmake complains, that "CMAKE_MAKE_PROGRAM is not set.", pls make sure, your mingw/bin folder is set in the path environment variable. If it is and cmake still complains, make a copy of your "make.exe" in its folder and rename this file to "mingw32-make.exe" (reference: http://stackoverflow.com/questions/6141608/cmake-make-program-not-found).
(or just drop there a file make.ba
t:
the/path/to/mingw32-make.exe
the/path/to/mingw32-make.exe install
)
If you want to set build options, you can do so as follows:
cmake -D <option name>=<option> <your nana location> -G "MinGW Makefiles"
this way you can set what kind of build you want
Debug
,
RelWithDebInfo
,
Release
or
MinSizeRel
use them like:
cmake -D CMAKE_BUILD_TYPE=<option> <your nana location> -G "MinGW Makefiles"
same is with the option nana gives you
you can turn them ON/OFF.
Currently available are:
NANA_ENABLE_PNG
,
NANA_LIBPNG
,
NANA_THREAD_NOT_SUPPORTED
and
NANA_UNICODE
by default all these options are ON
. Turn them OFF
if you want.
e.g. with my preference to not have PNG Support, the full commandline looks like this:
cmake -D CMAKE_BUILD_TYPE=MinSizeRel -D NANA_ENABLE_PNG=OFF -D NANA_LIBPNG=OFF m:\nana -G "MinGW Makefiles"
This part is written without a special ide/code editor in mind, as it should be very similar with most.
- create a new project
- make sure you set the compiler is at least in c++11 mode (compiler option
-std=c++11
) - add "nana/include" to your include-paths
- set the following preprocessor directives
NANA_UNICODE
andNANA_MINGW
(usually separated with a ';') - add the the path where you have built nana to to the library path
- add the following libraries to used libraries:
libnana.a
libgdi32.a
libcomdlg32.a
andlibz.a
- write a little nice programm
- compile
If you are using cmake
for your own programs you can reuse the CMakeLists.txt from nana-demo and follow the instruction from here or from our .tarvis.yml. You can see an example of the whole process "live" in travis
have fun with nana
With mingw-w64
In the previous use MinGW-W64 Online Installer instead of tdm-gcc.tdragon. You will probably have a more recent version of gcc.