rapidsai / cudf

cuDF - GPU DataFrame Library
https://docs.rapids.ai/api/cudf/stable/
Apache License 2.0
8.03k stars 871 forks source link

[QST] Error linking libcudftestutil.a. #10322

Closed TKONIY closed 2 years ago

TKONIY commented 2 years ago

I want to use some utilities in libcudftestutil.a but got some problems. Here's my program.

#include <cudf/aggregation.hpp>
#include <cudf/groupby.hpp>
#include <cudf/table/table.hpp>
#include <cudf_test/column_utilities.hpp>

template<typename T>
std::unique_ptr<cudf::column> MakeColumn() {
    int rowNum = 100;
    using storeType = int;

    std::vector<storeType> data(rowNum, 1000);
    rmm::device_buffer resultBitMask{cudf::bitmask_allocation_size_bytes(rowNum), rmm::cuda_stream_default};
    rmm::device_buffer rmmData(data.data(), rowNum * sizeof(storeType), rmm::cuda_stream_default);

    auto col = std::make_unique<cudf::column>(
            cudf::data_type(cudf::type_to_id<T>()),
            rowNum,
            std::move(rmmData),
            std::move(resultBitMask)
    );
    return col;
};

int main(int argc, char **argv) {
    auto col = MakeColumn<int>();
    cudf::test::print(col->view());
    return 0;
}

Here's my CMakeLists.txt.

cmake_minimum_required(VERSION 3.20)
project(learn_libcuDF CUDA)

set(CMAKE_CUDA_STANDARD 17)

add_executable(learn_libcuDF main.cu)

set_target_properties(learn_libcuDF PROPERTIES
        CUDA_SEPARABLE_COMPILATION ON)

target_include_directories(learn_libcuDF
        PUBLIC /home/dys/anaconda3/envs/cudf_dev/include)
target_link_libraries(learn_libcuDF
        PUBLIC /home/dys/anaconda3/envs/cudf_dev/lib/libcudf.so
        PUBLIC /home/dys/anaconda3/envs/cudf_dev/lib/libcudftestutil.a)

Here's part of the log.

/home/dys/anaconda3/envs/cudf_dev/lib/libcudftestutil.a(column_utilities.cu.o): In function `cudf::test::expect_equal_buffers(void const*, void const*, unsigned long)':
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8eed): undefined reference to `testing::Message::Message()'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8f1c): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8f2f): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8f3b): undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8f9f): undefined reference to `testing::Message::Message()'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8fce): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8fe1): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x8fed): undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x907c): undefined reference to `testing::Message::Message()'
tmpxft_0000e3b4_00000000-6_column_utilities.cudafe1.cpp:(.text+0x90a1): undefined reference to `testing::internal::GetBoolAssertionFailureMessage[abi:cxx11](testing::AssertionResult const&, char const*, char const*, char const*)'
jrhemstad commented 2 years ago

You're getting undefined references to GTest symbols. I believe you need to also link against Google Test like we do in our test configuration: https://github.com/rapidsai/cudf/blob/28813d74ba9bf4bb5750eb7b368139be418e9ece/cpp/tests/CMakeLists.txt#L34

jrhemstad commented 2 years ago

Oh, I think the problem is that you're linking against the .so and .a directly instead of linking against the cudf and cudftestutil cmake targets.

Checkout the basic libcudf example and it's CMake file using CPM to fetch libcudf and linking against the exported cmake targets. https://github.com/rapidsai/cudf/blob/28813d74ba9bf4bb5750eb7b368139be418e9ece/cpp/examples/basic/CMakeLists.txt#L29

TKONIY commented 2 years ago

Thanks a lot. I'm not familiar with CMake and CPM. Now I use the CMakeLists.txt in basic libcudf example, but got the error.

CMake Error at cmake-build-debug-dbgroup-v100s/_deps/cudf-src/cpp/cmake/thirdparty/get_arrow.cmake:144 (find_package):
  By not providing "FindArrowCUDA.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ArrowCUDA", but CMake did not find one.

  Could not find a package configuration file provided by "ArrowCUDA" with
  any of the following names:

    ArrowCUDAConfig.cmake
    arrowcuda-config.cmake

  Add the installation prefix of "ArrowCUDA" to CMAKE_PREFIX_PATH or set
  "ArrowCUDA_DIR" to a directory containing one of the above files.  If
  "ArrowCUDA" provides a separate development package or SDK, be sure it has
  been installed.

I have installed Apache Arrow using following script from the official cite. What else should I do?

image
github-actions[bot] commented 2 years ago

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] commented 2 years ago

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.