0

All

When I build cpp using g++ and glib, I meet compile error. c and gcc version is OK. I'm building at Ubuntu 10.XX. I even built it at windows - c++.

How can I build glib at c++? Thanks you.

#include <glib.h>

int main() {
    g_printf("test");
    return 0;
}

jongwon_kwak@kwak-com:~/worksapce_CXX/TESTGLib/src$ g++ -c -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include TESTGLib.cpp 
TESTGLib.cpp: In function ‘int main()’:
TESTGLib.cpp:12:17: error: ‘g_printf’ was not declared in this scope
jongwon.kwak
  • 143
  • 1
  • 7

2 Answers2

1

you are missing #include <glib/gprintf.h>

Valerij
  • 27,090
  • 1
  • 26
  • 42
0

Just edit this and it will work

#include <glib/gprintf.h>
Xavi López
  • 27,550
  • 11
  • 97
  • 161
Hafiz Muhammad Shafiq
  • 8,168
  • 12
  • 63
  • 121
  • This is not a valid solution. The Glib documentation clearly says that including `` is enough to get all the function/variable declarations. – Daniel Kamil Kozar Feb 21 '14 at 15:05