0

not sure if this is an appropriate question...

Im using netbeans, and have started to play about with gtk-3.0.

In Netbeans library manager I have added the path /usr/include/gtk-3.0. I have tried to compile a simple project which uses one of the gtk header files. It will not compile, states header file not found. I have checked the class path is correct and that the header file is in the specified location. But had no joy. (the headerfile I am using is gtkmm.h)

I then tried putting the same path into the include directories list in project properties, and the program compiles fine.

My question therefore is, does adding the path in netbeans library manager not automatically include it for my program? I thought this was the whole point? I am stuck with having to add my paths to each new project I create? I thought putting them into the library manager would make this unnecessary? I thought this was the whole point of library manager?

Dave0504
  • 1,057
  • 11
  • 30
  • What type of C/C++ project do you have? I used to create and maintain my own makefiles, so I understand them 100%. – HEKTO Jun 03 '14 at 20:03

1 Answers1

0

The simplest way is to create a NetBeans "project with existing sources". In order to begin you'll need a directory with only two files - a Makefile and one simple C++ program (with empty main function). However, the Makefile must know about the gtkmm. The pkg-config tool is your friend (in Unix/Linux environment). I have following gtkmm-related lines in my Makefile:

GTKMM_VERSION := gtkmm-3.0
CFLAGS += ${shell pkg-config --cflags ${GTKMM_VERSION}}
LDLIBS += ${shell pkg-config --libs ${GTKMM_VERSION}}

Then you'll need to create a new project in NetBeans - choose "C/C++ Project with existing sources" and tell the NetBeans where your directory is located. The NetBeans will find the Makefile automatically and will try to run it.

A good idea is to run the make in this directory even before creation a new NetBeans project - to make sure the Makefile does what you want.

HEKTO
  • 3,876
  • 2
  • 24
  • 45
  • Hetko, i resolved this through netbeans, but its not what i wanted originally. I wanted to learn how to set via pkg-config. i understand part of the code in your make file. The part i cant grasp is "shell pkg-config --flags" and "shell pk-config --libs". I think the this is calling the pkg-config from the shell with the arguments being --cflags/--libs? I dont understand how the flags can encompass the paths i want to include if i haven't physically typed them somewhere? I may have got the complete wrong end of the stick here though, so any help is welcome! – Dave0504 Jun 05 '14 at 22:13
  • actually, i think ive just grasped it. Does ${GTKMM_VERSION} contain a list of the where the GTKMM paths are found on my file system? – Dave0504 Jun 05 '14 at 22:18
  • The `pkg-config` is a tool, which allows you to read configuration files of various systems, which follow the `pkg-config` protocol. The gtkmm-3.0 does follow it. Its configuration file `gtkmm-3.0.pc` is located in the `/usr/lib/x86_64-linux-gnu/pkgconfig` directory on my system. Look for this directory, you might have it as well. All the configuration files in this directory follow the `pkg-config` protocol - so you can retrieve information about these systems universally by a single `pkg-config` tool. – HEKTO Jun 05 '14 at 23:08
  • Thanks Hekto. Im going to start from scratch and learn everything from a command line point of view before i get invloved any further with netbeans (and linux) as im new to both linux adn C/C++ programming. this will come in handy, goingto look into pkg-config in more detail as well. much appreciated. – Dave0504 Jun 07 '14 at 19:03