![]() |
liblocation, undefiend reference
Hello,
trying to compile example using: Code:
gcc -Wall `pkg-config --cflags glib-2.0, liblocation --libs glib-2.0, liblocation` -o gps gps.cpp Code:
/var/tmp/cc447Dm5.o: In function `main': maybe I'm tired, but I have no idea how to fix this :( I'm using final SDK for Maemo 5, same effect on both armel and x86. |
Re: liblocation, undefiend reference
Answering my own question:
adding Code:
extern "C" |
Re: liblocation, undefiend reference
Hi!
I encounter a similar problem and have long been looking for an answer to it, but no success so far. I get the same error message, even when trying it with the sample code. I am using the Virtual Image SDK and I am writing in C, though and the headers are of course included. Any hint on how to solve is very welcome. ES |
Re: liblocation, undefiend reference
Quote:
|
Re: liblocation, undefiend reference
Thanks for the heads-up, Joorin, surely nobody could help me with that little information, I understand.
Something had to be wrong with my first post... So, here goes, I am as well trying to compile the location API example code, as per the very first post in this thread. I am using the Virtual Image SDK in VMware on a Mac and I compile inside ESbox. Code:
gcc -O0 -g -o helloworldwithdebiansupport main.o -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgnomevfs-2 -lgconf-2 -lgthread-2.0 -lrt -lgmodule-2.0 -ldbus-glib-1 -ldbus-1 -lpthread -lgobject-2.0 -lglib-2.0 -pthread -lhildon-1 -lhildonfm -lgtk-x11-2.0 -lgnomevfs-2 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgconf-2 -lgthread-2.0 -lrt -lgmodule-2.0 -ldbus-glib-1 -ldbus-1 -lpthread -lgobject-2.0 -lglib-2.0 -losso -ldbus-glib-1 -ldbus-1 -lpthread -lgobject-2.0 -lglib-2.0 Code:
main.o: In function `on_changed': I hope that's sufficient information, please let me know if more is needed. |
Re: liblocation, undefiend reference
Quote:
Code:
-llocation |
Re: liblocation, undefiend reference
Quote:
|
Re: liblocation, undefiend reference
Thanks, Nicolai, that's what I "feel", too. And I have been trying to include this into the gcc-statement.
But I have no idea, how to add it. I assume(d) that ESbox would take care of the necessary libraries to include. If not, how can I add them manually to the compiler statement (in ESbox)? |
Re: liblocation, undefiend reference
Quote:
Code:
/* Includes */ Code:
src/main.c:63: error: expected ')' before '*' token |
Re: liblocation, undefiend reference
nicolai beat me to it.
Just as he pointed out, you have no instruction to the linker to look in liblocation for symbols that will satisfy the function calls in your code. The flag -l means "Add this library to the list of libraries to look for symbols in.". The flag -L means "Look in this directory for libraries to use while linking.". So, in this case, the combination Code:
-L/user/lib -llocation Happy (hacking|linking)! :) |
Re: liblocation, undefiend reference
Quote:
In said Makefile, the pkg-config system is used. This enables you to ask for specific compiler flags. Have a look at how it works and you'll get it in no time. To add flags by hand is easy too. Just copy and paste the compiler call in your terminal, add -llocation and press return. Tadah! |
Re: liblocation, undefiend reference
Allright, now we're getting somewhere... Thanks for the quick feedback everyone!
In my setup there are two "Makefile"-files, one in the source-folder "src", and one in the root folder of the project. I added -I/usr/lib to the DEPS_CFLAGS-attribute and -llocation to the DEPS_LIBS-attribute. No more compilation errors after that regarding the undefined references. |
Re: liblocation, undefiend reference
Just remember that case matter. "-L" is not the same thing as "-l".
So, either you did a typo while you wrote the previous message or you actually added "-l/usr/lib" which makes no sense to the linker. |
Re: liblocation, undefiend reference
Quote:
Quote:
In the Makefile-file in the root folder are several CFLAGS- and LIBS-attributes: DEPS, HILDON and OSSO. And in those, the directories are referenced with "-I" (capital "I", not small "L") ?!? Now I don't know to which of these attributes to add the flags for the location directory, but believe it or not, by doing as per my previous post ESbox succesfully compiles. Code:
make -k all "CFLAGS=-O0 -g" "CXXFLAGS=-O0 -g" So, compiling in ESbox completes without error, but the program does not run in Scratchbox. And creation of a Debian package fails, too. And since GPS emulation is not possible in ESbox/Scratchbox, I do have to export to run it on a N900 device. Console output for Debian package creation: Code:
dpkg-buildpackage: source package is template So, my questions are: -Where exactly do I have to add the flags in Makefile and in which Makefile (/src vs. root)? -How come it compiles locally but fails with the above error when creating a Debian package? -Where to read on documentation about how to configure this in ESbox? (I assumed ESbox would automatically take care of things like that.) |
Re: liblocation, undefiend reference
Quote:
eclipse build environment) just generates these Makefiles. If you change them your manual build may succeed but from within esbox or when building the package they are re-generated and your changes vanish? By the way, those compiler and linker flags are often set through pkg-config like "pkg-config --cflags --libs liblocation". Does esbox provide thome project settings where you can set dependency with pkg-config? |
Re: liblocation, undefiend reference
Quote:
Quote:
Currently it look as if I found a promising lead for this: In the "configure.ac" file I add "liblocation >= 0.1" to make it look like this: Code:
PKG_CHECK_MODULES(DEPS, gtk+-2.0 >= 2.2 glib-2.0 >= 2.2 gnome-vfs-2.0 >= 2.2 liblocation >= 0.1) It builds, I can create a Debian package, it installs on the N900 and it runs. :cool: More testing to be done, though... |
Re: liblocation, undefiend reference
And this configure.ac file is most likely generated by ESBox using some list of libraries that will be needed for the project. To be forced to add a dependency like this by modifying the file by hand looks like a bug in ESBox.
|
All times are GMT. The time now is 13:31. |
vBulletin® Version 3.8.8