I have a:
GFile* gf = g_file_new_for_path(file_path);
in my code. But when i try to compile it, I see error:
Undefined reference to: 'g_file_new_for_path'
In include section I have #include <gio/gio.h>
What's wrong in this code?
I have a:
GFile* gf = g_file_new_for_path(file_path);
in my code. But when i try to compile it, I see error:
Undefined reference to: 'g_file_new_for_path'
In include section I have #include <gio/gio.h>
What's wrong in this code?
I re-tagged your question, this is not GTK+, it's gio.
As you've discovered according to your comment, your problem was due to not linking with the proper libraries. This is because in C, merely including a header doesn't tell the compiler where to find the code that implements the things declared in that header. To do that, you typically need to link with the proper libraries (or compile the code directly, as you do inside your own projects).
The recommended way, by the way, to reference the libraries is using a tool such as pkg-config. Then the compilation would look something like this:
$ gcc -o mygiotest mygiotest.c $(pkg-config --cflags --libs glib-2.0 gobject-2.0 gio-2.0)
You need to double-check the above, I'm not in Linux as I type this so I can't verify the exact package names.