guitargeek / XGBoost-FastForest

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

make issue when build test.cpp.o #9

Closed cloudray8580 closed 4 years ago

cloudray8580 commented 4 years ago

Hi, I'm following the normal build procedure to build the library (under WSL) but encounter some link issues during make, do you have some suggestions? Thanks. Here is the log:

cloudray@LEGION7000:/mnt/d/XGBoost-FastForest/build$ cmake ..
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/local/lib/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: system filesystem unit_test_framework
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/XGBoost-FastForest/build

cloudray@LEGION7000:/mnt/d/XGBoost-FastForest/build$ make -j8
Scanning dependencies of target fastforest
[ 20%] Building CXX object CMakeFiles/fastforest.dir/src/common_details.cpp.o
[ 40%] Building CXX object CMakeFiles/fastforest.dir/src/fastforest.cpp.o
[ 60%] Linking CXX shared library libfastforest.so
[ 60%] Built target fastforest
Scanning dependencies of target Test
[ 80%] Building CXX object test/CMakeFiles/Test.dir/test.cpp.o
[100%] Linking CXX executable Test
/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `SerializationTest::test_method()':
test.cpp:(.text+0x2f7): undefined reference to `fastforest::FastForest::write_bin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: test.cpp:(.text+0x441): undefined reference to `fastforest::load_bin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: test.cpp:(.text+0x6ed): undefined reference to `fastforest::FastForest::evaluate(float const*, float*, int) const'
/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `ManyfeaturesTest::test_method()':
test.cpp:(.text+0x274c): undefined reference to `fastforest::FastForest::evaluate(float const*, float*, int) const'
/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `ExampleTest::test_method()':
test.cpp:(.text+0x4499): undefined reference to `fastforest::FastForest::evaluate(float const*, float*, int) const'
/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `SoftmaxArrayTest::test_method()':
test.cpp:(.text+0x61af): undefined reference to `fastforest::FastForest::evaluate(float const*, float*, int) const'
/usr/bin/ld: test.cpp:(.text+0x61bc): undefined reference to `fastforest::details::softmaxTransformInplace(float*, int)'/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `BasicTest::test_method()':
test.cpp:(.text+0x873c): undefined reference to `fastforest::FastForest::evaluate(float const*, float*, int) const'
/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `DiscreteTest::test_method()':
test.cpp:(.text+0xa704): undefined reference to `fastforest::FastForest::evaluate(float const*, float*, int) const'
/usr/bin/ld: CMakeFiles/Test.dir/test.cpp.o: in function `SoftmaxTest::test_method()':
test.cpp:(.text+0xc6c7): undefined reference to `fastforest::FastForest::softmax(float const*, int) const'
collect2: error: ld returned 1 exit status
make[2]: *** [test/CMakeFiles/Test.dir/build.make:88: test/Test] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: test/CMakeFiles/Test.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
guitargeek commented 4 years ago

Hi! What's your CMake version? Do you need the tests? Would disabling them be an option for you?

guitargeek commented 4 years ago

Nevermind, it has nothing to do with the tests. Your make log for fastforest is already problematic:

Scanning dependencies of target fastforest
[ 20%] Building CXX object CMakeFiles/fastforest.dir/src/common_details.cpp.o
[ 40%] Building CXX object CMakeFiles/fastforest.dir/src/fastforest.cpp.o
[ 60%] Linking CXX shared library libfastforest.so
[ 60%] Built target fastforest

It didn't compile the src/FastForest.cpp source, even though CMake is configured to do so: https://github.com/guitargeek/XGBoost-FastForest/blob/master/CMakeLists.txt#L15

Did you maybe delete src/FastForest.cpp by accident or change that like in CMakeLists.txt?

guitargeek commented 4 years ago

Okay, I fixed the problem. I guess your filesystem didn't understand that FastForest.cpp and fastforest.cpp were two separate files. My bad for giving them names that only differed by upper/lower case! Let me know if it works now so I can close the issue.

cloudray8580 commented 4 years ago

Thanks a lot, I successfully build the lib with your latest version.