c++ - 在C++中使用XGBoost时的 undefined symbol

标签 c++ xcode xgboost

我想在自己的XGBoost项目中包括C++库。这是我遵循的步骤:

  • 使用git从GitHub下载。
  • 使用make -j4
  • 编译XGBoost文件
  • 在XCode中,我将XGBoost路径添加到路径搜索中:search-paths
  • 在我的项目中,当我过去包含它时,可以找到XGBoost文件。
    但是,当我执行代码时,这是错误消息:enter image description here

  • 它说c_api.h中带有函数名的 undefined symbol
    有谁知道如何解决这个问题?
    如果我想在Linux中编译这些文件,我应该包括哪个命令以链接XGBoost库。非常感谢你的帮助!!

    最佳答案

    您设置了DYLD_LIBRARY_PATH吗?
    如果要在Linux上编译。说您在家中进行了以下操作:

    git clone --recursive https://github.com/dmlc/xgboost
    cd xgboost
    mkdir build
    cd build
    cmake ..
    make -j4
    
    您包含的路径是:
    -I ~/xgboost/include/xgboost
    
    该库将libxgboost.so将存在于〜/ xgboost / lib中
    为了与此库链接,您必须添加:
    -L ~/xgboost/lib -lxgboost
    
    由于它是一个共享库(.so),因此您必须修改LD_LIBRARY_PATH并将其导出。
    export LD_LIBRARY_PATH=~/xgboost/lib:$LD_LIBRARY_PATH
    
    ps:如果您不想修改LD_LIBRARY_PATH,另一个解决方案是添加
    -Wl,-rpath=~/xgboost/lib
    

    关于c++ - 在C++中使用XGBoost时的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63353699/

    相关文章:

    c++ - 如何制作可以接受任何类型参数的 std::functions 和 lambda

    C++ 使用 ifstream 加载 .txt 文件时出错

    ios - 如何从 xcode 仪器时间分析器获取挂钟时间?

    ios - 设置 statusbarStyle(iOS 9.0 中已弃用)

    iphone - Xcode 7.3.1弹出一个奇怪的bug是LaunchServiceError错误0

    python - 在 BaggingRegressor 中使用 xgboost

    c++ - 用于 C++ 的 FastCGI

    c++ - 在 C++ 中有效地解析日志文件的文本

    r - 将 xgboost TreeMap 导出到 R 中的图像

    python - 如何使用 python 将混淆矩阵记录到 azureml 平台