Problems compiling gtkmm

前端 未结 2 1659
后悔当初
后悔当初 2021-02-04 04:54

OS: Fedora 14

Compiler: g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

I installed gtkmm24-devel from repository via yum. To make sure the install went as planned I

2条回答
  •  梦谈多话
    2021-02-04 05:35

    Short answer

    Use the output of 'pkg-config gtkmm-2.4 --cflags' for include paths and 'pkg-config gtkmm-2.4 --libs' for libraries to link.

    Long answer

    It said it couldn't find gtkmm.h, no problem, I just forgot to link the library.

    Building a C/C++ program is done in two separate steps. First the source files are compiled, outputting object files; and then the object files are linked together. The error you are getting comes from the compiling step.

    On Linux, most libraries come with pkgconfig files to make it easier for other programs to use the libraries. gtkmm also comes with its own pkgconfig files.

    You are trying to manually specify /usr/include/gtkmm-2.4 for include path; this is wrong. Instead, use the output of pkgconfig to figure out where the header files are located. To get all the include directories needed for gtkmm, use the following command:

    pkg-config gtkmm-2.4 --cflags
    

    For linking, use the following pkgconfig command to get the libraries you need to link with:

    pkg-config gtkmm-2.4 --libs
    

    You can test it on the command line by invoking g++ directly.

    g++ myfirstprogram.cpp -o myfirstprogram `pkg-config gtkmm-2.4 --cflags --libs`
    

    For more information, see the gtkmm docs: http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-basics-simple-example.html.en

提交回复
热议问题