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

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. But I can't understand why it doesn't occur error at gcc & c version.
0

Just edit this and it will work

#include <glib/gprintf.h>

1 Comment

This is not a valid solution. The Glib documentation clearly says that including <glib/glib.h> is enough to get all the function/variable declarations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.