Conan - 오픈소스 C++ 패키지 매니저
https://www.slideshare.net/uilianries/conanio-the-cc-package-manager-for-developers
설치
Linux
pip 설치하기
x# 버전 확인(python3)
$ python3 -V
Python3.5.2
# pip 설치
$ sudo apt install python3-pip
conan 설치하기
xxxxxxxxxx
$ pip3 install --user conan
conan에서 관리하는 패키지 찾기
xxxxxxxxxx
$ conan search <package> -r=all
# example
$ conan inspect spdlog/1.4.2@bincrafters/stable
-r=all 안 붙이면 local에서 찾는다
옵션 설정하기
xxxxxxxxxx
$ conan profile new default --detect # Generates default profile detecting GCC and sets old ABI
$ conan profile update settings.compiler.libcxx=libstdc++11 default # Sets libcxx to C++11 ABI
현재 쓰고있는 GCC 컴파일러 버전이 5.1 이상이면, 구버전과의 호환성을 위해 compiler.libcxx로 구버전 ABI를 설정한단다. 무슨 말인지 모르겠지만 설정한다.
C++ 라이브러리 설치하기
xxxxxxxxxx
$ mkdir ~/myproject
$ cd ~/myproject
$ vi conanfile.txt
------------------------------
# conanfile.txt
[requires]
fmt/6.0.0@bincrafters/stable
spdlog/1.4.2@bincrafters/stable
[generators]
cmake
------------------------------
# [options]를 사용하면 링크를 동적, 정적으로 지정할 수 있다
# fmt 패키지는 spdlog의 의존패키지
https://docs.conan.io/en/latest/using_packages/conanfile_txt.html 참고
conanfile.txt가 있는 경로에서 아래 명령어 실행
xxxxxxxxxx
$ mkdir build && cd build
$ conan install .. --build=spdlog --build=fmt # ..은 conanfile.txt 파일이 있는 경로
conanfile가 있는 프로젝트를 처음
conan install
할 경우 패키지가 빌드되어 있지 않다. 파라미터로 빌드하도록 지정해야한다.--build=spdlog --build=fmt
위 명령어가 끝나면 아래 파일이 만들어진다
xxxxxxxxxx
conanbuildinfo.cmake # 필요
conanbuildinfo.txt # 필요
conanfile.txt
conaninfo.txt
graph_info.json # 필요
conan.lock
빌드한 패키지가 위치하는 곳
xxxxxxxxxx
/home/$USER/.conan/data/spdlog/1.10.0/spdlogproject/stable/pacakge/add7f61ec32c64be9e81a4a56a44300046913e86/
xxxxxxxxxx
$ ls -l
LICENSE
conaninfo.txt
conanmanifest.txt
include/ # spdlog 헤더파일
lib/ # spdlog 라이브러리
설치 패키지 사용하기
directory
xxxxxxxxxx
myproject/
build/
src/
main.cpp
CMakeLists.txt
conanfile.txt
CMakeLists.txt
xxxxxxxxxx
cmake_minimum_required(VERSION 3.1)
project(rbccpp)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(main src/main.cpp)
target_link_libraries(main ${CONAN_LIBS})
conanfile.txt
xxxxxxxxxx
[requires]
fmt/6.0.0@bincrafters/stable
spdlog/1.4.2@bincrafters/stable
[generators]
cmake
main.cpp
xxxxxxxxxx
int main(int argc, char* argv[]){
std::cout<< "cout.. hello world" << std::endl;
spdlog::set_level(spdlog::level::trace);
spdlog::info("spdlog info.. {}", "hello world");
spdlog::warn("spdlog warn.. {:02x}", 255);
spdlog::debug("spdlog debug.. {:05.2f}", 3.141592);
spdlog::error("spdlog error.. {}", 'c');
spdlog::critical("spdlog critical.. {}", "이 메세지가 표시되어야 함");
return EXIT_SUCCESS;
}
실행
$ cd build
$ conan install .. --build=spdlog --build=fmt
$ cmake ..
$ make
$ ./bin/main
댓글
댓글 쓰기