guitargeek / XGBoost-FastForest

Minimal library code to deploy XGBoost models in C++.
MIT License
86 stars 30 forks source link

Linking error for build C++ test #12

Closed jiaboli007 closed 3 years ago

jiaboli007 commented 3 years ago

I got the following linking error when I compile my test code: undefined reference to `fast forest::loadtxt(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >&)'

Here is my test code:

include

include

include

include

include

include

include

include

include "fastforest.h"

include

int main() { std::vector features{"f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",\ "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19",\ "f20","f21","f22","f23","f24","f25","f26","f27","f28","f29"};

const auto fastForest = fastforest::load_txt("model.txt", features);

std::vector<float> input{1, 0, 6, 4, 0, 0, 0, 1, 6, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0};

float bond_length = fastForest(input.data());
std::cout << "Bond Length = " << bond_length << "\n";

}

Any help will be highly appreciated! Thanks.

guitargeek commented 3 years ago

Hi @jiaboli007! How did you install the fastforest library, and how are you building your test code?

I compiles fastforest with make install, took your code and compiled it with g++ -o test test.cc -lfastforest. No problem!

Did you remember the -lfastforest flag to link against the library?

guitargeek commented 3 years ago

Was the problem solved? Can the issue be closed?

guitargeek commented 3 years ago

I'll close this CMake support issue.