英文:
How to create GTK3 app with CMake and Eclipse CDT on Windows
问题
CMakeList.txt
cmake_minimum_required (VERSION 2.6)
project (EITSoftGTK)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
# 设置CMake以使用GTK+,告诉编译器在哪里查找头文件
# 并告诉链接器在哪里查找库文件
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
# 向编译器添加其他标志
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
add_executable(EITSoftGTK EITSoftGTK.cpp)
# 将目标链接到GTK+库
TARGET_LINK_LIBRARIES(EITSoftGTK ${GTK3_LIBRARIES})
请注意,这是CMake的配置文件,用于构建GTK3应用程序。如果您需要更多帮助或有其他问题,请随时提出。
英文:
I trying create simple gtk3 app for windows. Gtk3 has been installed with official instruction by mysys. I created cmake app in eclipse. I tried create simple gtk3 app and it compiled successful, but Eclipse show errors. And when I run compiled app it failed.
cmake_minimum_required (VERSION 2.6)
project (EITSoftGTK)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
# Setup CMake to use GTK+, tell the compiler where to look for headers
# and to the linker where to look for libraries
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
# Add other flags to the compiler
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
add_executable(EITSoftGTK EITSoftGTK.cpp)
# Link the target to the GTK+ libraries
TARGET_LINK_LIBRARIES(EITSoftGTK ${GTK3_LIBRARIES})
答案1
得分: 2
你需要确保所有依赖项都可以访问。官方文档描述了DLL的定位方式,但最简单的方法是将缺失的DLL文件(libgio...
和libgobject...
)复制到与可执行文件相同的目录中。
英文:
As I remarked in my comment, you need to make sure all dependencies are accessible. The official documentation describes how DLLs are located, but by far the easiest is to copy the missing DLLs (libgio...
and libgobject...
) into the same directory as your executable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论