[英]How to add OpenXLSX to my project in c++?
我有一个项目,我想使用 OpenXLSX 作为 excel 库。 但是,我无法将其添加到我的项目中。 我将所有 OpenXLSX 文件移动到我的项目文件夹中,但它不起作用。 也将它们移到我的桌面,它也不起作用。
这是我的 CMakeList.txt 文件:
#cmake_minimum_required(VERSION 3.5)
#project(PCL_Visualizer LANGUAGES CXX)
#set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
#add_executable(PCL_Visualizer main.cpp)
cmake_minimum_required(VERSION 3.5)
project(mainwindow)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# init_qt: Let's do the CMake job for us
set(CMAKE_AUTOMOC ON) # For meta object compiler
set(CMAKE_AUTORCC ON) # Resource files
set(CMAKE_AUTOUIC ON) # UI files
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/home/fatih/Desktop")
# Find the QtWidgets library
find_package(Qt5 REQUIRED Widgets)
find_package(VTK REQUIRED)
find_package(PCL 1.7.1 REQUIRED)
find_package(OpenXLSX REQUIRED)
# Fix a compilation bug under ubuntu 16.04 (Xenial)
#list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")
include_directories(${PCL_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/OpenXLSX-master)
#include_directories(OpenXLSX-master/library/headers)
#include_directories(OpenXLSX-master/library/external/pugixml)
#include_directories(OpenXLSX-master/library/external/nowide/nowide)
#include_directories(OpenXLSX-master/library/external/zippy)
add_definitions(${PCL_DEFINITIONS})
set(project_SOURCES main.cpp mainwindow.cpp)
add_executable(${PROJECT_NAME} ${project_SOURCES} icons.qrc)
target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES} Qt5::Widgets)
每次我尝试 cmake.. 并制作时,我都会收到此错误。
Could not find a package configuration file provided by "OpenXLSX" with any
of the following names:
OpenXLSXConfig.cmake
openxlsx-config.cmake
Add the installation prefix of "OpenXLSX" to CMAKE_PREFIX_PATH or set
"OpenXLSX_DIR" to a directory containing one of the above files. If
"OpenXLSX" provides a separate development package or SDK, be sure it has
been installed.
我只是将这些命令添加到我的 CMakeList.txt 并部分解决了问题。
include_directories(/home/fatih/Desktop/OpenXLSX-master/library)
include_directories(/home/fatih/Desktop/OpenXLSX-master/build/library)
include_directories(/home/fatih/Desktop/OpenXLSX-master/library/headers)
link_directories(/home/fatih/Desktop/OpenXLSX-master/build/library)
link_directories(/home/fatih/Desktop/OpenXLSX-master/build/library/headers)
link_directories(/home/fatih/Desktop/OpenXLSX-master/library/headers)
target_link_libraries(${PROJECT_NAME} OpenXLSX VERSION 0.2.0 LANGUAGES CXX)
但是,现在我得到了不同类型的错误。
/usr/bin/ld: cannot find -lOpenXLSX
/usr/bin/ld: cannot find -lVERSION
/usr/bin/ld: cannot find -l0.2.0
/usr/bin/ld: cannot find -lLANGUAGES
/usr/bin/ld: cannot find -lCXX
/usr/bin/ld: cannot find -lOpenXLSX
/usr/bin/ld: cannot find -lVERSION
/usr/bin/ld: cannot find -l0.2.0
/usr/bin/ld: cannot find -lLANGUAGES
/usr/bin/ld: cannot find -lCXX
编辑:我也解决了这个问题。 如果有人收到这样的错误,我将 target_link_library 注释更改为:
target_link_libraries(${PROJECT_NAME} /home/fatih/Desktop/OpenXLSX-master/build/output/libOpenXLSX-shared.so)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.