Setting up GTKmm in Eclipse for C++

回眸只為那壹抹淺笑 提交于 2019-12-02 13:23:30

问题


I am trying to create a GUI using GTKmm in Eclipse, however I can't get the configuration working. 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. 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:

${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


回答1:


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. I followed the procedure twice and it worked both times.

Create Project:

File -> New -> C++ Project

Project Type: Executable -> Hellow World Gtkmm Project

Toolchains: Linux GCC

Project Properties:

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

See if that works for you.




回答2:


I have a brief article about this (with screenshots), see it here:

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




回答3:


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

First I installed the pkg-config Eclipse Plugin:
https://code.google.com/p/pkg-config-support-for-eclipse-cdt/

Then:

  • Created a new empty C++ project in Eclipse
  • Added three files to the project (helloworld.cpp, helloworld.h, main.cc)
  • Added pkg-config-support to the project: [(right click on Project) -> Properties -> C++ Build -> Settings -> Pkg-config -> (checkmark) gtkmm-3.0 -> OK
  • From Eclipse I Cleaned, then Build all, then was able to Run the example.


来源:https://stackoverflow.com/questions/26079171/setting-up-gtkmm-in-eclipse-for-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!