如何在Windows上使用CMake和Eclipse CDT创建GTK3应用程序

huangapple go评论80阅读模式
英文:

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.

如何在Windows上使用CMake和Eclipse CDT创建GTK3应用程序
CMakeList.txt

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})

如何在Windows上使用CMake和Eclipse CDT创建GTK3应用程序
如何在Windows上使用CMake和Eclipse CDT创建GTK3应用程序

如何在Windows上使用CMake和Eclipse CDT创建GTK3应用程序

答案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.

huangapple
  • 本文由 发表于 2020年1月3日 18:59:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/59577365.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定