kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

How to compile new api? #133

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi
I am interested in yamp-cpp, and I want to know how to compile new api and it's 
library file. Because I got old api defaultly.
Thanks!

Original issue reported on code.google.com by Garcia.relax@gmail.com on 15 Nov 2011 at 6:59

GoogleCodeExporter commented 8 years ago
When you run cmake, add the argument -DYAML_CPP_BUILD_OLD_API=OFF

Original comment by jbe...@gmail.com on 15 Nov 2011 at 7:11

GoogleCodeExporter commented 8 years ago
Thanks!
But now I have another error when I compile my test program, see attach:

And my test code is:
#include "yaml-cpp/node/parse.h"
#include "yaml-cpp/node/node.h"

#include <string>
#include <iostream>
#include <fstream>

using namespace std;

int main (int argc, char const* argv[])
{
    fstream fin("./1.yaml");
    YAML::Node config = YAML::Load(fin);
    cout << config["username"].as<string>() << endl;
    fin.close();
    return 0;
}
Is my test code right?

Original comment by Garcia.relax@gmail.com on 15 Nov 2011 at 11:11

Attachments:

GoogleCodeExporter commented 8 years ago
You aren't linking with yaml-cpp. You need to pass gcc the argument -lyaml-cpp, 
and make sure that libyaml-cpp.a is in your linker path.

Original comment by jbe...@gmail.com on 15 Nov 2011 at 4:29