Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Set and Compile First C++ Project Properly.(Set and Compile First C++ Project Properly (Gtkmm).)
Set and Compile First C++ Project Properly. [message #1716914] Wed, 09 December 2015 02:06 Go to next message
Erick sriro is currently offline Erick sriroFriend
Messages: 12
Registered: December 2015
Junior Member
Hi,

How do I set and create my first project in Eclipse?
My OS is Ubuntu Studio 14.04 64 bit.
I have my eclipse-cpp-mars-1-linux-gtk-x86_64 installed in my OS just now.
I also successfully installed "Pkg-config Support for Eclipse CDT 1.00".

My goal is to create a hello word program (Gtkmm), which would always run in Ubuntu Linux and Windows only.

Here are my questions.

1. From the menu File -> New -> C++ Project,
- What should I choose as a "Project type"? I am guessing that it should be "Executable" -> "Hello World Gtkmm Project"
- What should I choose from "Toolchains"?

2. Do I need to install anything else beside "Pkg-config Support for Eclipse CDT 1.00"?
I do have libgtkmm-3.0-dev installed in my Ubuntu already.

3. How do I set something like this in Eclipse setting?
$ g++ HelloGtkmm.cpp -o HelloGtkmm `pkg-config gtkmm-3.0 --cflags --libs`

Once my hello word program (Gtkmm) executes in Ubuntu and Windows, I should be able to move on.

Thanks so much.
Re: Set and Compile First C++ Project Properly. [message #1717083 is a reply to message #1716914] Wed, 09 December 2015 20:49 Go to previous messageGo to next message
Erick sriro is currently offline Erick sriroFriend
Messages: 12
Registered: December 2015
Junior Member
Hi,

Here are the steps that I found over the internet.
However, I could not get any of my Hello World program to work yet.

1. Fresh installation of Eclipse IDE.
2. Install Plugin "Pkg-config support for C++ CDT 1.0.0".
3. File -> New -> C++ Project.
- Project Name -> Gtkmm
- Project Type -> Hello World Gtkmm Project
- Toolchains -> Linux GCC
4. Project Explorer -> Right Click my project name "Gtkmm" -> Properties -> C/C++ Build -> Setting

4.a "Pkg-config" tab -> Checked "gtkmm-3.0"

4.b "Tool Settings" Tab -> GCC C++ Compiler

All options:
-I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/gtk-3.0 -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/atk-1.0 -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/harfbuzz -I/usr/include/gtkmm-3.0/ -O0 -g3 -Wall -c -fmessage-length=0

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

4.c "Tool Settings" tab -> GCC C++ Linker
Command line pattern: ${COMMAND} `pkg-config --libs gtkmm-3.0` ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

5. Project -> Clean..
6. Project -> Build All

From here can you let me know how to complie and run my Hello World program?
Re: Set and Compile First C++ Project Properly. [message #1717085 is a reply to message #1717083] Wed, 09 December 2015 20:52 Go to previous messageGo to next message
Erick sriro is currently offline Erick sriroFriend
Messages: 12
Registered: December 2015
Junior Member
This is how I get my Hello World to work without Eclipse, which I would get an executable file.

$ g++ HelloGtkmm.cpp -o HelloGtkmm `pkg-config gtkmm-3.0 --cflags --libs`

Re: Set and Compile First C++ Project Properly. [message #1717105 is a reply to message #1717085] Wed, 09 December 2015 22:27 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I have never been able to get the pkg-config CDT plugin to work.
The way I have gotten around it is to make two Build Variables (Project ==> C/C++ Build ==> Build Variables) and use the output from pkg-config on the command line. Afterwards, I add the appropriate variable to the compile and link commands.

add PKGCFLAGS and cut and paste the output from "pkg-congif -cflags <lib>" as the value.
add PKGLFLAGS cutting and pasting from "pkg-congif -libs <lib>"

Project ==> C/C++ Build ==>Settings in the Tool Settings dialog
add ${PKCFLAGS} to the compile command line and
add ${PKGLFLAGS} to the linker command.

Of course the variable names can be anything you like.

Another way around it is to build your own make file. You could let Eclipse do it once then prevent Eclipse from doing it again.
Re: Set and Compile First C++ Project Properly. [message #1717110 is a reply to message #1717105] Thu, 10 December 2015 00:31 Go to previous message
Erick sriro is currently offline Erick sriroFriend
Messages: 12
Registered: December 2015
Junior Member
Wow!

It works now as you can see below.

16:23:34 **** Incremental Build of configuration Debug for project Gtkmm ****
make all
Building target: Gtkmm
Invoking: GCC C++ Linker
g++ `pkg-config --libs gtkmm-3.0` -o "Gtkmm" ./src/Gtkmm.o ./src/HelloWorld.o -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -lgtkmm-3.0 -latkmm-1.6
Finished building target: Gtkmm


16:23:35 Build Finished (took 1s.56ms)

Thanks so much.
Previous Topic:Best fallback for debugging msvc builds built by cdt
Next Topic:how do you compile eclipse itself?
Goto Forum:
  


Current Time: Fri Apr 26 08:57:26 GMT 2024

Powered by FUDForum. Page generated in 0.03562 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top