简体   繁体   English

在Eclipse中为C ++设置GTKmm

[英]Setting up GTKmm in Eclipse for C++

I am trying to create a GUI using GTKmm in Eclipse, however I can't get the configuration working. 我正在尝试在Eclipse中使用GTKmm创建GUI,但是无法使配置正常工作。 For reference, here is my actual code: 供参考,这是我的实际代码:

#include <gtkmm.h>

using namespace std;

int main(int argc, char **argv) {
    Gtk::Main kit(argc,argv);
    Gtk::Window frmMain;

    kit.run(frmMain);

    return 0;
}

These are the settings I have entered under the GCC C++ Compiler section. 这些是我在“ GCC C ++编译器”部分下输入的设置。 All options: 所有选项:

-I/usr/include/gtkmm-3.0 -I/usr/include/gdkmm-3.0 -I/usr/include/gtk-3.0 -O0 -g3 -Wall

and for Command Line Pattern: 对于命令行模式:

${COMMAND} `pkg-config gtkmm-3.0 --cflags` ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

Finally, under the GCC G++ Linker section, I have this entered for the Command Line Pattern: 最后,在“ GCC G ++链接器”部分下,为命令行模式输入了以下内容:

${COMMAND} `pkg-config gtkmm-3.0 --libs` ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}

Here is a link to my compile log: http://pastebin.com/tfqv97w6 这是我的编译日志的链接: http : //pastebin.com/tfqv97w6

I can't put this in the comments they are too restrictive. 我不能在它们过于严格的评论中加以说明。 These are the steps I have just gone through to make a gtkmm program in my eclipse. 这些是我在eclipse中制作gtkmm程序所经历的步骤。 I followed the procedure twice and it worked both times. 我按了两次程序,两次都奏效。

Create Project: 创建项目:

File -> New -> C++ Project 文件->新建-> C ++项目

Project Type: Executable -> Hellow World Gtkmm Project 项目类型:可执行-> Hellow World Gtkmm项目

Toolchains: Linux GCC 工具链:Linux GCC

Project Properties: 项目属性:

C/C++ Build -> Settings -> Pkg-config -> gtkmm-3.0 C / C ++ Build->设置-> Pkg-config-> gtkmm-3.0

See if that works for you. 看看是否适合您。

I performed two test. 我进行了两次测试。 One with your source instance and one with an instance from a simple file from the site. 一个带有源实例,另一个带有来自站点中简单文件的实例。 Both worked flawlessly the first time using the steps below. 两者首次使用以下步骤都可以正常工作。

A Hello World example from the gtkmm website with Success: https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/helloworld gtkmm网站上的Hello World示例,显示成功: https : //git.gnome.org/browse/gtkmm-documentation/tree/examples/book/helloworld

First I installed the pkg-config Eclipse Plugin: 首先,我安装了pkg-config Eclipse插件:
https://code.google.com/p/pkg-config-support-for-eclipse-cdt/ https://code.google.com/p/pkg-config-support-for-eclipse-cdt/

Then: 然后:

  • Created a new empty C++ project in Eclipse 在Eclipse中创建了一个新的空C ++项目
  • Added three files to the project ( helloworld.cpp , helloworld.h , main.cc ) 向项目添加了三个文件( helloworld.cpphelloworld.hmain.cc
  • Added pkg-config-support to the project: [(right click on Project) -> Properties -> C++ Build -> Settings -> Pkg-config -> (checkmark) gtkmm-3.0 -> OK 向项目添加了pkg-config-support:[(右键单击Project)->属性-> C ++ Build->设置-> Pkg-config->(选中标记)gtkmm-3.0->确定
  • From Eclipse I Cleaned , then Build all , then was able to Run the example. 从Eclipse中,我Cleaned ,然后Build all ,然后能够Run示例。

I have a brief article about this (with screenshots), see it here: 我有关于此的简短文章(带有屏幕截图),请在此处查看:

http://www.hamedandobaideh.com/index.php/9-uncategorised/73-gtkmm-with-eclipse http://www.hamedandobaideh.com/index.php/9-uncategorised/73-gtkmm-with-eclipse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM