0

我从这里克隆了 scintilla https://github.com/mirror/scintilla 我已经构建了 scintilla GTK+/Linux 版本,现在在 bin 文件夹中生成了 scintilla.a。我在我的 CMAkeList.txt 文件中处理了这个库,但是当我构建我的应用程序,我收到此错误“致命错误:Scintilla.h:没有这样的文件或目录”[build] 4 | #include <Scintilla.h>

所以我不知道为什么它找不到 scintilla.h ...我应该在我的 cmakelists.txt 文件中添加更多内容吗?...当我包含这一行时 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/scintilla/include) ,我得到一堆新的错误,例如:

/home/sob/.landscape/ScintillaExample/main.cpp:17:5: error: ‘ScintillaObject’ was not declared in this scope
[build]    17 |     ScintillaObject* sci;
[build]       |     ^~~~~~~~~~~~~~~
[build] /home/sob/.landscape/ScintillaExample/main.cpp:17:22: error: ‘sci’ was not declared in this scope
[build]    17 |     ScintillaObject* sci;

这就是我的 cmakelists.txt 文件的样子:

cmake_minimum_required(VERSION 3.1)
project(ScintillaExample) 
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)  
SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)  
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/scintilla/bin)
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/scintilla/include)
add_library(scintilla.a STATIC IMPORTED)
set_property(TARGET scintilla.a PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/scintilla/bin/scintilla.a)
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
#set(SCINTILLA_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/scintilla/bin/scintilla.a)
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
ADD_EXECUTABLE(app main.cpp)
TARGET_LINK_LIBRARIES(app ${GTK3_LIBRARIES})

如果你能告诉我如何解决这个问题,我将不胜感激

4

1 回答 1

0

我对我的 cmakefilelists.txt 进行了一些更改,现在它正在工作:

cmake_minimum_required(VERSION 3.1)
project(ScintillaExample) 
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)  
SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)  
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/scintilla/bin)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/scintilla/include)
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
ADD_EXECUTABLE(app main.cpp)
TARGET_LINK_LIBRARIES(app ${CMAKE_CURRENT_SOURCE_DIR}/scintilla/bin/scintilla.a ${GTK3_LIBRARIES} gmodule-2.0)
${CMAKE_CURRENT_SOURCE_DIR}/scintilla/bin/scintilla.a)
于 2020-10-15T07:14:29.270 回答