LibYAML is a library for easily handling YAML files in C language developed and published at http://pyyaml.org/wiki/LibYAML.
$ sudo apt-get install libyaml-dev
$ apt-cyg install libyaml-devel
It is written on the assumption that apt-cyg is installed.
--From the source code
$ wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
$ tar zxvf yaml-0.1.5.tar.gz
$ cd yaml-0.1.5
$ ./configure --prefix=$HOME/rootfs
$ make
$ make install
When installing from source, you can use "--prefix" to install in the specified directory, so you can install even on a server whose root privileges are not published. (I think that the same thing can be done with apt-get and apt-cyg by expanding the package archive to the home directory etc., maybe.)
When you open A libyaml Tutorial, you can see the sample yaml file and the sample source for reading and writing.
--For Linux
$ gcc -lyaml test.c
I think that the library can be compiled either before or after the source file.
--For Cygwin
$ gcc test.c -lyaml
It may be environment dependent, but the order of gcc command options seems to be fixed. If you do not specify the library in the order of source file → library, compilation will not pass. (Maybe my compilation environment is special ...)
--When installed in a file path other than the default file path
$ gcc -I${HOME}/rootfs/include/ -L${HOME}/rootfs/lib/ test.c -lyaml
Specify the directory path where yaml.h is stored with "-I", and specify the directory where libyaml.a is stored with "-L".
Recommended Posts