[Lemon-user] Building Lemon 1.3.1 on Windows

Alpar Juttner alpar at cs.elte.hu
Thu Apr 23 09:33:41 CEST 2015


Hi,

> I tried out the new CMake 3.2.2.

Ok, I did it too.

> I instructed the installer to add CMake to the PATH.
> It failed to do that, so I had to manually add its folder to the PATH
> user variable.

Ok, that's certainly not LEMON's fault. :)
(Btw. it worked for me)

> Then I run it, with these settings
> Where is the source code: lemon-1.3.1
> Where to build the binaries: lemon-1.3.1/lemon/build

Why not lemon-1.3.1/build?

> Then I ticked the option "Suppress dev Warnings (-Wno-dev)".

It is again strange. I didn't have to do anything like that.

> I clicked Configure, [...]
> When I opened the .sln file in Visual Studio 2013, I found a lot of
> projects (far more than 4), some look like tests.
> I built the ALL_BUILD one.
> This time it didn't give me any include error. You can find the log
> attached.
> The absence of errors seems to be due to the fact that I set the
> source code folder to "lemon-1.3.1" instead of "lemon-1.3.1\lemon".

YES! Is should be set to the root, not to the include dir!

> 
> It all seems fine, however, if I try to
> #include <lemon/something.h> 
> inside a different VS2013 project, they don't get recognized.
> 
> Even setting "Additional Include Directiories" in the Project ->
> Properties -> C/C++ doesn't help.
> Is there something else I have to do?
> Other PATH stuff, or different configurations?
> 
> By the way, there is no LEMON folder in
> C:\Program Files (x86)
> even though the CMake configuration seems to suggest it should have
> been created.

For that you must build the "INSTALL" target.

> I'm doing my best here, but I'm not used to advanced build systems.
> Can I just copy-paste .cc and .h files in my project, without going
> through CMake and VS?

It is possible - tough I would not recommend. In fact, it is often a
valid idea to embed lemon's source code to your project. But CMAKE has a
fine support doing that, so you shouldn't do it by hand.

In general there are three recommended ways of using lemon:
     1. Install it somewhere, then tell VS where the headers and the
        libraries are located (alas, in Windows there are no standard
        location for them)
     2. Simply put your code into the contrib/ dir and edit
        contrib/CMakeFiles.txt accordingly. Then you code will be
        compiled together with other parts of lemon.
     3. Create a CMAKE build environment to your own project and add
        LEMON as a subproject. To help this, we provide a template that
        can be customized with minimal efforts, see
        https://lemon.cs.elte.hu/trac/lemon/wiki/ProjectTemplate

I usually recommend option 2 for simple projects, or when you plan to
add new stuff to LEMON itself. On the other hand, option 3 it the
ultimate solution if you develop a larger project and want to maintain a
self-contained, always consistent code tree. (You can add other open
source libraries to your code in similar ways)
Some more info is found here:
https://lemon.cs.elte.hu/trac/lemon/wiki/HowToCompile

If you still would like to ember LEMON to your project by hand, the
following steps should be done.
      * Copy all lemon headers to your project. Be careful to keep the
        original directory layout.
      * There is one system dependent include file - lemon/config.h -
        which is not in the release, but instead generated by CMAKE. So
        have CMAKE generate it, find it somewhere in the build
        directory, then copy it into the 'lemon' directory (where the
        other include files sit). Of course this will make your code
        less portable.
      * Add the directory one level up to 'lemon' to the include path.
      * Add LEMON's .cc file you need to your projects. You must always
        add lemon/base.cc and lemon/bits/windows.cc

But one again, I still recommend you to get familiar CMAKE. It is a
great tool to manage the build process of both tiny and huge projects
(and anything in between).

Alpár




More information about the Lemon-user mailing list