Skip to content

Install and use nana with mingw step by step

Timtanium edited this page Apr 25, 2019 · 30 revisions

--> Please read: Troubleshooting-MinGW

Prerequisites

Make sure you have the following already installed:

compiling nana step by stept - gui version

  1. go to your mingw folder and start "open_distro_window.bat". A Terminal window should occure.
  2. go to the folder you want nana inserted to
  3. type "git clone https://github.com/cnjinhao/nana.git"
  4. go into nana's new folder ("cd nana")
  5. download the current hotfix branch via "git checkout -t origin/hotfix-1.3" (optional step)
  6. start cmake (gui version)
  7. chose where the source code is (its the newly created nana folder: git created it for you)
  8. chose a folder where you want the compilat at (button "browse build")
  9. click "generate"
  10. as of now, on my machines I need to reload the cache files, do this via "Menu-->File-->Reload Cache"
  11. 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.
  12. click generate
  13. close cmake
  14. in the terminal window (opened with step 1) go to the folder you have chosen for the build folder
  15. type "make" to create the library
  16. type "make install" to create in the directory you selected to install nana (by default CMAKE_INSTALL_PREFIX) two directories: lib with the compiled library, and include 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)

compiling nana step by stept - non-gui version

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.bat:

  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"

compiling your own application with nana step by step

This part is written without a special ide/code editor in mind, as it should be very similar with most.

  1. create a new project
  2. make sure you set the compiler is at least in c++11 mode (compiler option -std=c++11)
  3. add "nana/include" to your include-paths
  4. set the following preprocessor directives NANA_UNICODE and NANA_MINGW (usually separated with a ';')
  5. add the the path where you have built nana to to the library path
  6. add the following libraries to used libraries: libnana.a libgdi32.a libcomdlg32.a and libz.a
  7. write a little nice programm
  8. 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

Prerequisites

In the previous use MinGW-W64 Online Installer instead of tdm-gcc.tdragon. You will probably have a more recent version of gcc.

This and this may help.

Clone this wiki locally