平台Archlinux,直接yay
安装xgboost,相关的.h文件会被直接安装到/usr/include/xgboost
路径下,所有在CMakeLists.txt
设置include_directories
到该路径下即可。
cmake_minimum_required(VERSION 3.18)
project(project_name LANGUAGES C CXX VERSION 0.1)
set(xgboost_DIR "/usr/include/xgboost")
include_directories(${xgboost_DIR})
link_directories(${xgboost_DIR})
add_executable(project_name test.c)
target_link_libraries(project_name xgboost)
在c文件中直接调用头文件
#include "xgboost/c_api.h"
编译使用cmake
mkdir build
cd ./build
cmake ..
make
./project_name