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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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.