Setting up GTKmm in Eclipse for C++ - c++

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

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.

I have a brief article about this (with screenshots), see it here:
http://www.hamedandobaideh.com/index.php/9-uncategorised/73-gtkmm-with-eclipse

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.

Related

Using CodeLite IDE for OpenCV in Ubuntu 16.04 LTS

I can compile a sample C++ Code (including OpenCV) using both CMake and following command line:
g++ cv.cpp -o cvapp pkg-config --cflags --libs opencv
But I want to use CodeLite IDE for this purpose. I have added
/usr/include/opencv;/usr/include/opencv2
in the Include Paths under compiler tab in project settings. And added
/usr/local/lib
in Libraries Search Path under Linker tab.
But still, I am getting errors shown in this screenshot for a sample code.
Now is it possible to use CodeLite for OpenCV coding environment? If yes then how?
To use opencv in codelite the simplest option is to continue using pkg-config, you can do this as follows:
Right click on the project name and select settings...
2.Open the following dialog and select the Linker tab, in that window add pkg-config --cflags --libs opencv in linker-options:
Press the apply button and Ok and then compile the project.

Compilation error with gtkmm

I'm trying to compile a simple helloworld programme on eclipse using gtkmm and compiling with mingw32 through mingw32.
I followed these instructions to "install" gtkmm:
https://wiki.gnome.org/Projects/gtkmm/MSWindows
I also read a lot of threads about that topic but couldn't understand why i'm not able to compile this simple program:
#include <gtkmm.h>
int main(int argc, char** argv)
{
auto app = Gtk::Application::create(argc, argv);
Gtk::Window window;
window.set_default_size(600,400);
return app->run(window);
}
Through eclipse IDE i used the
project=>properties=>C/C++build=>settings=>pkg-config
and i enabled gtkmm-3.0.
Then i compile and i get the error:
Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
g++ -I/mingw32/include/gtkmm-3.0 -I/mingw32/lib/gtkmm-3.0/include -I/mingw32/include/atkmm-1.6 -I/mingw32/include/gdkmm-3.0 -I/mingw32/lib/gdkmm-3.0/include -I/mingw32/include/giomm-2.4 -I/mingw32/lib/giomm-2.4/include -I/mingw32/include/pangomm-1.4 -I/mingw32/lib/pangomm-1.4/include -I/mingw32/include/glibmm-2.4 -I/mingw32/lib/glibmm-2.4/include -I/mingw32/include/gtk-3.0 -I/mingw32/include/cairo -I/mingw32/include -I/mingw32/include/pango-1.0 -I/mingw32/include/atk-1.0 -I/mingw32/include/cairomm-1.0 -I/mingw32/lib/cairomm-1.0/include -I/mingw32/include/pixman-1 -I/mingw32/include/freetype2 -I/mingw32/include/libpng16 -I/mingw32/include/harfbuzz -I/mingw32/include/glib-2.0 -I/mingw32/lib/glib-2.0/include -I/mingw32/include/sigc++-2.0 -I/mingw32/lib/sigc++-2.0/include -I/mingw32/include/gdk-pixbuf-2.0 -I/mingw32/includ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -o main.o "..\\main.cpp"
..\main.cpp:1:19: fatal error: gtkmm.h: No such file or directory
compilation terminated.
What is strange is that i can see in the compile log that it include everything needed for this program.
i also tried to add in
project=>properties=>C/C++build=>settings=>tool settings=> gcc c++
compiler and mingw linker
the result of pkg-config gtkmm-3.0 --cflags --libs but i get the exact same error.
It makes 2 days that i'm reading and trying the same propositions i found everywhere but coudn't get a result.
So please can someone try to help me to found a way to get this simple example to work.
thank you a lot
(ps: sorry for my mistakes)
I had the same problem, i solved it by manually adding all this path to include (Project Prorepties > C/C++ Build > Settings > GCC C++ Compiler > Includes > Include Paths (-I)):
"C:\msys64\mingw32\include\gtkmm-3.0"
"C:\msys64\mingw32\lib\gtkmm-3.0\include"
"C:\msys64\mingw32\include\glibmm-2.4"
"C:\msys64\mingw32\lib\glibmm-2.4\include"
"C:\msys64\mingw32\include\glib-2.0"
"C:\msys64\mingw32\lib\glib-2.0\include"
"C:\msys64\mingw32\include\sigc++-2.0"
"C:\msys64\mingw32\lib\sigc++-2.0\include"
"C:\msys64\mingw32\include\giomm-2.4"
"C:\msys64\mingw32\lib\giomm-2.4\include"
"C:\msys64\mingw32\include\gdkmm-3.0"
"C:\msys64\mingw32\lib\gdkmm-3.0\include"
"C:\msys64\mingw32\include\pangomm-1.4"
"C:\msys64\mingw32\include\gtk-3.0"
"C:\msys64\mingw32\include\pango-1.0"
"C:\msys64\mingw32\lib\pangomm-1.4\include"
"C:\msys64\mingw32\include\cairo"
"C:\msys64\mingw32\include\gdk-pixbuf-2.0"
"C:\msys64\mingw32\include\cairomm-1.0"
"C:\msys64\mingw32\include\freetype2"
"C:\msys64\mingw32\include\atkmm-1.6"
"C:\msys64\mingw32\include\atk-1.0"
"C:\msys64\mingw32\include\gtkmm-3.0"
"C:\msys64\mingw32\include\glibmm-2.4"
(You shoud replace "C:\msys64\mingw32" with your mingw32 path)
Also add -std=c++11 flag (Project Prorepties > C/C++ Build > Settings > GCC C++ Compiler > Miscellaneous > Other flags) and
glibmm-2.4
gtkmm-3.0
to (Project Prorepties > C/C++ Build > Settings > MinGW C++ Linker > Libraries (-l))

Code Building Error in Eclipse CDT for Player/Stage simulator

I am using Player/Stage for my thesis work. But, I am getting undefined reference error messages while I want to build this code in Eclipse CDT-
#include <iostream>
#include <playerc++.h>
#include <playerclient.h>
#include <clientproxy.h>
using namespace std;
int main()
{
PlayerClient robot("localhost",6665);
return 0;
}
The error message is:
08:40:02 **** Build of configuration Debug for project firstTest ****
make all
Building file: ../src/firstTest.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/include/player-3.0/libplayerc++ -include/usr/local/include/player-3.0/libplayerc++/playerc++.h -include/usr/local/include/player-3.0/libplayerc++/clientproxy.h -include/usr/local/include/player-3.0/libplayerc++/playerc++config.h -include/usr/local/include/player-3.0/libplayerc++/playerclient.h -include/usr/local/include/player-3.0/libplayerc++/playererror.h -include/usr/local/include/player-3.0/libplayerc++/utility.h -O0 -g3 -Wall -c -fmessage-length=0 `pkg-config --cflags playerc++` -MMD -MP -MF"src/firstTest.d" -MT"src/firstTest.d" -o "src/firstTest.o" "../src/firstTest.cpp"
Finished building: ../src/firstTest.cpp
Building target: firstTest
Invoking: GCC C++ Linker
g++ `pkg-config --libs playerc++` -o "firstTest" ./src/firstTest.o
./src/firstTest.o: In function `main':
/home/nafees/workspace/firstTest/Debug/../src/firstTest.cpp:19: undefined reference to `PlayerCc::PlayerClient::PlayerClient(std::string, unsigned int, int)'
/home/nafees/workspace/firstTest/Debug/../src/firstTest.cpp:19: undefined reference to `PlayerCc::PlayerClient::~PlayerClient()'
collect2: error: ld returned 1 exit status
make: *** [firstTest] Error 1
08:40:02 Build Finished (took 514ms)
I have followed this nice tutorial posted by Jenny- http://yorkroboticist.blogspot.com/2010/03/playerstage-on-eclipse.html
In this link you will get the snapshots of my Eclipse Project Properties:
https://www.dropbox.com/sh/9hcmditufu0lt6v/AAChqD1-FMM9FhvTWpuOGMQ-a?dl=0
I have tried a lot of ways to remove this error. but, all in vein. Please help me to continue my thesis.
With thanks
Nafees
I have figured out the "undefined reference" problem.....
If anyone wants to use eclipse CDT for stage/player simulation, please follow these steps. I am assuming that you have installed the Player/Stage properly.
Go to Project Properties.
Expand C/C++ Build.
Click on Settings.
If you want to build C++ code, follow these steps-
Under GCC C++ Compiler, click on Miscellaneous tab.
There is a box named "Other flags". Paste this line(with ` symbols) on the box-
`pkg-config --cflags playerc++`
caution: Never edit the existing lines in the box. Just paste the above line beside the existing line with an space. And keep in mind ' and ` is not same.
Then, go to includes/directories(name may vary according to eclipse version) tab. There is an "include paths(-I)" box. click on add button and navigate to- Computer > usr > local > include > Player- x.x and press ok.
If you want to build C code, Skip number 4 instruction and follow these steps instead-
Under GCC C Compiler, click on Miscellaneous.
There is a box named "Other flags". Paste this line (with ` symbol) on the box-
`pkg-config --cflags playerc`
caution: Never edit the existing lines in the box. Just paste the above line beside the existing one it with an space. And keep in mind ' and ` is not same
Go to includes/directories(names may vary according to eclipse version) tab. There is an "include paths(-I)" box. click on add button and navigate to- Computer > usr > local > include > Player- x.x and press ok.
Now, The most important steps come here. Under GCC C++ Linker, click on Miscellaneous tab. There is a box named "Linker flags".
if you are using C++, paste the following line-
`pkg-config --libs playerc++`
If you are using C, paste the following line instead of the above-
`pkg-config --libs playerc`
Now, go to Libraries tab and there you will see "Libraries (-l)" box. Press add button and
If you are using C++, paste the line-
playerc++
If you are using C, paste the following line instead of the above-
playerc
Finally, there is a box named "Library search path (-L)" beneath. Click on add button and navigate to- Computer > usr > local > lib and click ok.
Thats it....... Now try to compile and build an example code. :) :) :)

C++ Not Finding Installed Library

I am desperately trying to install WebKitGTK+, but I have hit a two-hour impasse.
For one, the tarball provided on the website does not seem to follow any of the typical "build from source" conventions, and there are no instructions anywhere. Any build-from-source instructions they provide involve the unstable repository version, which I do not want to use...and anyhow, those do not seem to work.
I can find both the Webkit (libwebkitgtk-3.0-dev) and Webkit2 (libwebkit2gtk-3.0-dev) versions on the repository (I love Synaptic Package Manager), but though I've installed them, C++ (CodeBlocks) fails on...
#include <webkit/webkit.h>
It is worth noting that one of my employees installed the same package (libwebkitgtk-3.0-dev) successfully from the Debian Wheezy repositories, and he can use them in his code just fine, with the same import statement.
I added the path to /usr/include/webkitgtk-3.0/webkit under Global Compiler Settings --> Search Directories --> Compiler. My employee and I both have the exact same paths to this library added - his work, mine don't.
I'm losing my mind now. Help?
In Codeblocks go to the Project Build Options settings. You can get there by right clicking on the project in the "Projects Management" panel on the left side of the screen and choosing 'Build Options' then clicking on the project itself(NOT just the debug/release options) in the window that shows up. Click the "Search Directories" tab and in the compiler subtab you will need to enter the following path:
/usr/include/webkitgtk-3.0/
When adding them make sure you DO NOT add it as a relative path. Additionally in the "Compiler Settings" -> "Other Options" tab you might need to add one or more of:
`pkg-config --cflags gtk+-3.0 `
`pkg-config --cflags glib-2.0 `
`pkg-config --cflags pango `
`pkg-config --cflags cairo `
`pkg-config --cflags gdk-pixbuf-2.0 `
`pkg-config --cflags atk `
`pkg-config --cflags libsoup-2.4 `
On my system I could not get pkg-config to work for webkitgtk itself.

Compiler Errors when trying to build very simple gtkmm app:

I installed gtkmm 3 on Ubuntu 13.04 using aptitude (I like aptitude because it remembers what was installed when you want to remove it):
sudo aptitude install libgtkmm-3.0-dev --with-recommends
Using codelite 5.1.2 and the default gtk++ tool chain, in my compiler include paths I added:
/usr/include/gtkmm-3.0 - the path to gtkmm.h
I tried to build the first sample app in Programming with GTKMM:
#include <gtkmm.h>
int main ( int argc, char *argv[] )
{
Gtk::Main kit ( argc, argv );
Gtk::Window window;
Gtk::Main::run ( window );
return 0;
}
After chasing down a few 'include file not found' errors coming from gtkmm.h, which includes the entire gtkmm framework, my compiler include path now looks like this:
/usr/include/gtkmm-3.0
/usr/include/glibmm-2.4
/usr/lib/i386-linux-gnu/glibmm-2.4/include
/usr/include/glib-2.0
And all hell is breaking loose from glib.h:
/bin/sh -c 'make -j 4 -e -f "Calendars_wsp.mk"'
----------Building project:[ CalendarsGUI - Debug ]----------
........
/gtkmm-3.0 -I/usr/include/glibmm-2.4 -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I//usr/include/glib-2.0
In file included from //usr/include/glib-2.0/glib/gtypes.h:36:0,
from //usr/include/glib-2.0/glib/galloca.h:34,
from //usr/include/glib-2.0/glib.h:32,
from /usr/include/glibmm-2.4/glibmm/thread.h:46,
from /usr/include/glibmm-2.4/glibmm.h:87,
from /usr/include/gtkmm-3.0/gtkmm.h:87,
from main.cpp:16:
***//usr/include/glib-2.0/glib/gversionmacros.h:179:2: error: #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"***
In file included from //usr/include/glib-2.0/glib/galloca.h:34:0,
from //usr/include/glib-2.0/glib.h:32,
from /usr/include/glibmm-2.4/glibmm/thread.h:46,
from /usr/include/glibmm-2.4/glibmm.h:87,
from /usr/include/gtkmm-3.0/gtkmm.h:87,
from main.cpp:16:
***//usr/include/glib-2.0/glib/gtypes.h:448:2: error: #error unknown ENDIAN type
.......
make: *** [All] Error 2
2 errors, 2 warnings***
(I also had the same problems when trying to use gtkmm 2.4)
Obviously I am missing something here. What am I doing wrong? What else do I need to do to build gtkmm projects?
When using gtkmm, its advised to use the pkg-config tool.
You can do this from codelite as well:
Right click on your project: Settings -> Common Settings -> Compiler -> C++ Compiler options:
and add:
$(shell pkg-config gtkmm-3.0 --cflags)
If you have another options, they should be semi-colon delimited
Next, add the following to the linker options:
Right click on your project: Settings -> Common Settings -> Linker -> Options:
$(shell pkg-config gtkmm-3.0 --libs)
again, if you have another options, they should be semi-colon delimited
Remove all the hard coded include paths you added the above 2 should suffice
Note:
This exact question was also answered on codelite's forum:
http://forums.codelite.org/viewtopic.php?f=11&t=1396&p=6416&hilit=gtkmm#p6410
Eran
Don't fiddle with includes, use pkg-config instead:
g++ foo.cc -o foo `pkg-config gtkmm-3.0 --cflags --libs`
btw, your example compiles and runs just fine.