Active Topics

 


Reply
Thread Tools
hopbeat's Avatar
Posts: 516 | Thanked: 643 times | Joined on Oct 2009 @ Denmark/Poland
#1
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
I'm getting errors:

Code:
/var/tmp/cc447Dm5.o: In function `main':
gps.cpp:(.text+0x2c): undefined reference to `location_gpsd_control_get_default()'
gps.cpp:(.text+0x38): undefined reference to `location_gps_device_get_type()'
/var/tmp/cc447Dm5.o: In function `start_location(void*)':
gps.cpp:(.text+0x16c): undefined reference to `location_gpsd_control_start(_LocationGPSDControl*)'
/var/tmp/cc447Dm5.o: In function `on_changed(_LocationGPSDevice*, void*)':
gps.cpp:(.text+0x280): undefined reference to `location_gpsd_control_stop(_LocationGPSDControl*)'

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.
__________________
Hi! I'm a Maemo Greeter!
Witaj na talk.maemo.org!

Useful links for newcomers:
Użyteczne linki:
Nowi użyktownicy mówią cześć | New members say hello , Tu zaczynają nowi użytkownicy | New users start here, Podforum społeczności | Community subforum, Wiki dla początkujących | Beginners' wiki page, Maemo5 101, Często zadawane pytania | Frequently Asked Questions (FAQ), Google

Jeżeli mogę w czymś pomóc, pytaj!
If I can help with anything else, just ask!

Bored? Follow me
 
hopbeat's Avatar
Posts: 516 | Thanked: 643 times | Joined on Oct 2009 @ Denmark/Poland
#2
Answering my own question:

adding

Code:
extern "C"
{
#include <location/location-gps-device.h>
#include <location/location-gpsd-control.h>
}
may prove useful. It was a long day...
__________________
Hi! I'm a Maemo Greeter!
Witaj na talk.maemo.org!

Useful links for newcomers:
Użyteczne linki:
Nowi użyktownicy mówią cześć | New members say hello , Tu zaczynają nowi użytkownicy | New users start here, Podforum społeczności | Community subforum, Wiki dla początkujących | Beginners' wiki page, Maemo5 101, Często zadawane pytania | Frequently Asked Questions (FAQ), Google

Jeżeli mogę w czymś pomóc, pytaj!
If I can help with anything else, just ask!

Bored? Follow me
 

The Following 2 Users Say Thank You to hopbeat For This Useful Post:
Posts: 13 | Thanked: 1 time | Joined on Apr 2010 @ Helsinki
#3
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
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#4
Originally Posted by ESmith View Post
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
As always: submit exact compiler command together with exact error output. Without that, it's almost impossible to guess what's going on.
 

The Following User Says Thank You to Joorin For This Useful Post:
Posts: 13 | Thanked: 1 time | Joined on Apr 2010 @ Helsinki
#5
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
And the errors are:
Code:
main.o: In function `on_changed':
/home/maemo/workspace/helloworld-withDebianSupport/src/main.c:79: undefined reference to `location_gpsd_control_stop'
main.o: In function `start_location':
/home/maemo/workspace/helloworld-withDebianSupport/src/main.c:92: undefined reference to `location_gpsd_control_start'
main.o: In function `main':
/home/maemo/workspace/helloworld-withDebianSupport/src/main.c:198: undefined reference to `location_gpsd_control_get_default'
/home/maemo/workspace/helloworld-withDebianSupport/src/main.c:199: undefined reference to `location_gps_device_get_type'
collect2: ld returned 1 exit status
make[2]: *** [helloworldwithdebiansupport] Error 1
make[2]: Target `all-am' not remade because of errors.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

*** exited with code 2
I can't understand, why the references are not found/defined?!?


I hope that's sufficient information, please let me know if more is needed.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#6
Originally Posted by ESmith View Post
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
I can't understand, why the references are not found/defined?!?
At least:
Code:
 -llocation
nicolai
 

The Following User Says Thank You to nicolai For This Useful Post:
Andre Klapper's Avatar
Posts: 1,665 | Thanked: 1,649 times | Joined on Jun 2008 @ Praha, Czech Republic
#7
Originally Posted by ESmith View Post
Code:
gcc  -O0 -g   -o helloworldwithdebiansupport
And the errors are:
Code:
main.o: In function `on_changed':
/home/maemo/workspace/helloworld-withDebianSupport/src/main.c:79: undefined reference to `location_gpsd_control_stop'
What are the exact #include lines in your source file? Are you sure you link to the correct header files for location_gpsd*?
__________________
maemo.org Bugmaster
 
Posts: 13 | Thanked: 1 time | Joined on Apr 2010 @ Helsinki
#8
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)?
 
Posts: 13 | Thanked: 1 time | Joined on Apr 2010 @ Helsinki
#9
Originally Posted by Andre Klapper View Post
What are the exact #include lines in your source file? Are you sure you link to the correct header files for location_gpsd*?
Thanks for the quick reply!

Code:
/* Includes */
#include <location/location-gps-device.h>
#include <location/location-gpsd-control.h>
#include <hildon/hildon-program.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkbutton.h>
#include <libosso.h>
#include <string.h>
#include <stdlib.h>
#include "localisation.h"
Leaving the "location"-headers away or modifying them brings up different errors:

Code:
src/main.c:63: error: expected ')' before '*' token
src/main.c:69: error: expected ')' before '*' token
src/main.c:82: error: expected ')' before '*' token
src/main.c: In function 'start_location':
src/main.c:90: error: 'LocationGPSDControl' undeclared (first use in this function)
src/main.c:90: error: (Each undeclared identifier is reported only once
src/main.c:90: error: for each function it appears in.)
src/main.c:90: error: expected expression before ')' token
src/main.c: In function 'main':
src/main.c:188: error: 'LocationGPSDControl' undeclared (first use in this function)
src/main.c:188: error: 'control' undeclared (first use in this function)
src/main.c:189: error: 'LocationGPSDevice' undeclared (first use in this function)
src/main.c:189: error: 'device' undeclared (first use in this function)
src/main.c:197: error: 'LOCATION_TYPE_GPS_DEVICE' undeclared (first use in this function)
src/main.c:200: error: 'LOCATION_METHOD_USER_SELECTED' undeclared (first use in this function)
src/main.c:201: error: 'LOCATION_INTERVAL_DEFAULT' undeclared (first use in this function)
src/main.c:204: error: 'on_error' undeclared (first use in this function)
src/main.c:205: error: 'on_changed' undeclared (first use in this function)
src/main.c:206: error: 'on_stop' undeclared (first use in this function)
make[2]: Leaving directory `/home/maemo/workspace/helloworld-withDebianSupport'
make[1]: Leaving directory `/home/maemo/workspace/helloworld-withDebianSupport'
make[2]: *** [main.o] Error 1
make[2]: Target `all-am' not remade because of errors.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

*** exited with code 2
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#10
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
will instruct the linker to look in /usr/lib for something that matches "liblocation.so.*". In most cases you don't have to supply the "-L/usr/lib" flag since the compiler has been instructed to look there by the people that configured it.

Happy (hacking|linking)!

Last edited by Joorin; 2010-04-28 at 09:13. Reason: Typo
 

The Following User Says Thank You to Joorin For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 16:05.