0

I have tried to ´make´ the library yaml-cpp, not sure I did it right, but how do I build it? In the tutorial (https://github.com/jbeder/yaml-cpp/blob/master/README.md) it says to run cmake in the build dir, but cmake could not find the cmakelist file, so I did it in the source dir, but then what? How do I build it?

If someone could make a newbie step by step to get the library (or any library really) so I can include it in my code, that would be awesome.

Im using Windows 7, and compiling using terminal (using Codeblocks MinGW gcc/g++) and sublime text 3 editor.

Edit: I have not "make". How can I get this?

JemoeE
  • 580
  • 2
  • 6
  • 15
  • 1
    You mean to ask how to use **CMake** (I don't see how this issue is specific to **yaml-cpp**)? Basically what you do is run the `cmake` command (if you do it inside the *build* dir it would be `cmake ..`) and then build using whichever build system you use (maybe its **make**?) – UnholySheep Oct 28 '16 at 15:24
  • I have edited the title. I have no "make"... How do I get it? – JemoeE Oct 28 '16 at 15:32
  • 1
    If you are using MinGW you should have **mingw32-make** – UnholySheep Oct 28 '16 at 15:34

1 Answers1

2

Here is the step by step guide: For the purpose of this answer I will use cmake gui instead to highlight a few key points.

  1. go to https://github.com/jbeder/yaml-cpp and download the root library.
  2. open cmake gui and select the source directory as <my project>/yaml-cpp-master

  3. select a directory for the build. I would call it <my project>/yaml-cpp-master/codeblocks_build

  4. press configure and then check all the values.

  5. press generate and wait for it to complete.

  6. Find the generated codeblocks project file within <my project>/yaml-cpp-master/codeblocks_build

  7. Compile the project as you normally would.

  8. find the generated DLL files and link them to your project.

The reason why you are getting this error is because cmake is trying to find the source code in the directory build which is newly created as seen in the tutorial:

mkdir build
cd build

This is meant to specify to cmake where to build it in rather than where to build from. If you wish to use it via a command line you will need to tell cmake where to build and where the source is.

To then call the functions from that library you will need to link the header files (files that start with .h or .hpp) and the DLL libraries.

the .cpp .c etc is where the implementation is but .h .hpp is where the definitions are.

So when you are including like this: #include<something.h> you are including definitions which are later filled by the .cpp files however in case of a library they are instead filled from .dll or .o

Avalon
  • 66
  • 2
  • 6
  • Awesome! Thank you for this. In 7. "Compile the project as you normally would." - can you please be more specific? I normally use gcc file.cpp -o file. Would that work? – JemoeE Oct 28 '16 at 15:52
  • 1
    it will generate a custom makefile in the project directory. You are using codeblocks so opening it up with codeblocks and clicking on build/compile should be enough. Just make sure that you are using the same compiler that you specified in cmake. – Avalon Oct 28 '16 at 15:59
  • I will try that! Its because im try to do everything from terminal, but it would probably be easier to use the IDE build – JemoeE Oct 28 '16 at 16:00
  • 1
    Yeah you may want to look into what commands codeblocks runs when it compiles a makefile. But generally making it work with the IDE first and then seeing how it does that can be easier than going with the terminal alone. I think you will need mingw32-make.exe and then use the generated makefile. – Avalon Oct 28 '16 at 16:07