koide3 / small_gicp

Efficient and parallel algorithms for point cloud registration [C++, Python]
MIT License
318 stars 40 forks source link

Compile error from 01_basic_registration.cpp use MinGW-w64 compiler #31

Closed caibf closed 3 months ago

caibf commented 3 months ago

I have compiled small_gicp from the source code under the MinGW-w64 environment on Windows 10.

Then I try to compile the demo code 01_basic_registration.cpp and run it. CMakeLists.txt file of this code is like this.

cmake_minimum_required(VERSION 3.14.0)
project(small_gicp_demo LANGUAGES C CXX VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Specify to use the GCC compiler
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)

# Find OpenMP
find_package(OpenMP)

include_directories(./3rdparty ./3rdparty/Eigen3/include/eigen3)
add_executable(small_gicp_demo main.cpp)
# Add your executable and link OpenMP if it's found
if(OpenMP_CXX_FOUND)
    target_link_libraries(small_gicp_demo PUBLIC OpenMP::OpenMP_CXX)
endif()
target_link_directories(small_gicp_demo PUBLIC)
target_link_libraries(small_gicp_demo PUBLIC libsmall_gicp.dll.a)

The cmake command configure is ok. But fail to compile when I do make. It told me cannot find -lsmall_gicp. Could you help me?

$ make -j
[ 50%] Linking CXX executable small_gicp_demo.exe
D:/Programs/MinGW/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsmall_gicp
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles\small_gicp_demo.dir\build.make:104: small_gicp_demo.exe] Error 1
make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/small_gicp_demo.dir/all] Error 2
make: *** [Makefile:90: all] Error 2
caibf commented 3 months ago

Sorry, it's the path problem. I have solved it. Current solution is modify the CMakeLists.txt file, then modify the following codes.

target_link_libraries(small_gicp_demo PUBLIC /absolute path/libsmall_gicp.dll.a)