how to generate lib and include lib on windows?
Answered
- I have already download https://github.com/jbeder/yaml-cpp, and built it with clion, so i got "libyaml-cpp.a" in my workpath "D:\github\yaml-cpp\cmake-build-debug".
- Then I created new project(C++ Executable) , and modifed CMakeLists.text like this below:
cmake_minimum_required(VERSION 3.10)
project(testyaml)
link_directories(D:/github/yaml-cpp/cmake-build-debug)
include_directories(D:/github/yaml-cpp/include/yaml-cpp)
set(CMAKE_CXX_STANDARD 11)
add_executable(testyaml main.cpp)
#find_package (libyaml-cpp)
target_link_libraries(testyaml libyaml-cpp)
- In my main.cpp, code like this:
#include <iostream>
#include <fstream>
#include <string>
#include "yaml.h"
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
- But when I build my project , Clion can't find yaml-cpp/parser.h. Is there something wrong with my CMakeList.txt?
"D:\Program Files\JetBrains\apps\CLion\ch-0\181.4668.70\bin\cmake\bin\cmake.exe" --build D:\github\testyaml\cmake-build-debug --target testyaml -- -j 2
Scanning dependencies of target testyaml
[ 50%] Building CXX object CMakeFiles/testyaml.dir/main.cpp.obj
In file included from D:\github\testyaml\main.cpp:4:0:
D:/github/yaml-cpp/include/yaml-cpp/yaml.h:10:29: fatal error: yaml-cpp/parser.h: No such file or directory
#include "yaml-cpp/parser.h"
Please sign in to leave a comment.
Hello!
Thanks for replay!
I have done fellow your replay, but when i build my project , still get error:
Please edit the line with target_link_libraries in the following way:
It works!!!
Thanks very much, appreciate it!!
It troubled me few weeks!