我使用cmake生成我的项目,但我得到这些错误。
Scanning dependencies of target las2vtk
[ 50%] Building CXX object CMakeFiles/las2vtk.dir/LAS2VTK.cxx.o
[100%] Building CXX object CMakeFiles/las2vtk.dir/PointSet.cxx.o
Linking CXX executable las2vtk
CMakeFiles/las2vtk.dir/LAS2VTK.cxx.o: In function `main':
LAS2VTK.cxx:(.text+0xf1): undefined reference to `PointSet<PointND<3, float> >::read_LAS(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int)'
LAS2VTK.cxx:(.text+0x104): undefined reference to `PointSet<PointND<3, float> >::write_VTK(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
collect2: ld returned 1 exit status
make[2]: *** [las2vtk] Error 1
make[1]: *** [CMakeFiles/las2vtk.dir/all] Error 2
make: *** [all] Error 2
我很困惑,为什么当他们都写在PointSet.cxx这些功能是不确定的。 下面是我的CMakeLists.txt文件。 目前PointSet.h,PointSet.cxx和LAS2VTK.cxx都在同一个文件夹,但我可能会改变这种状况。
cmake_minimum_required(VERSION 2.8)
PROJECT(las2vtk)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(SOURCES PointSet.cxx)
set(LASLIBS_INCLUDE "${CMAKE_MODULE_PATH}/lastools/laslib/inc")
set(LASLIBS_LIB "${CMAKE_MODULE_PATH}/lastools/laslib/lib")
include_directories(${LASLIBS_INCLUDE})
link_directories(${LASLIBS_LIB})
set(LASLIBS las)
add_executable(las2vtk LAS2VTK.cxx ${SOURCES})
target_link_libraries(las2vtk ${LASLIBS})
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
if(VTK_LIBRARIES)
target_link_libraries(las2vtk ${VTK_LIBRARIES})
else()
target_link_libraries(las2vtk vtkHybrid )
endif()
它编译就好了,当我有我的函数定义我PointSet.h文件中并没有PointSet.cxx文件,但我想清理代码库。