Linking le_pos_Get2DLocation Error

I am trying to make a small program to fetch the 2d location like below for mangoh red wp76xx

#include <stdio.h>
#include “legato.h”
#include “le_info_interface.h”
#include “le_pos_interface.h”

int main(int argc, char** argv)
{
LE_INFO(“Fetcing 2D location \n”);
le_result_t res;
int32_t latitude = 0;
int32_t longitude = 0;
int32_t hAccuracy = 0;

res = le_pos_Get2DLocation(&latitude, &longitude, &hAccuracy);

if (res == LE_OK)
{
    LE_INFO("Location: latitude=%d, longitude=%d, hAccuracy=%d", latitude, longitude, hAccuracy);
}
else if (res == LE_FAULT)
{
    LE_INFO("Failed to get the 2D location's data");
}
else if (res == LE_OUT_OF_RANGE)
{
    LE_INFO("One of the retrieved parameter is invalid (set to INT32_MAX)");
}
else
{
    LE_INFO("unknown location error (%d)", res);
}

}

Below is the compilation link error which I am facing.

mangoh@mangoh-vm:~/legato_framework/legato/apps/sample/legacy/useLegatoApi$ $CC -c main.c -I$LEGATO_ROOT/framework/include

mangoh@mangoh-vm:~/legato_framework/legato/apps/sample/legacy/useLegatoApi$ $CC -o legacy main.o le_info_client.o -L$LEGATO_ROOT/build/wp76xx/framework/lib -llegato -lpthread -lrt
main.o: In function main': main.c:(.text+0xa8): undefined reference tole_pos_Get2DLocation’
collect2: error: ld returned 1 exit status
mangoh@mangoh-vm:~/legato_framework/legato/apps/sample/legacy/useLegatoApi$

Am I missing some dependency. Is the right way to fetch 2d location from legacy app.

Thanks

Hiya @abinayak88,

It looks like you’re missing a library in your link command.

I just had a look in liblegato.so (for the WP7702), and it looks like that library doesn’t provide any of the le_pos_XXX functions.

To look in a Shared library to see what functions it exports, you can use the following command:

nm -D /path/to/lib.so

and look for lines that have a hex string and a T before the function name.

I ran

nm -D $LEGATO_ROOT/build/wp77xx/framework/lib/liblegato.so | grep " T le_"

to get a list of all the legato functions published in liblegato.so … and there were no le_pos_ functions listed.

There’s a bunch of other libraries in the same directory … but there’s nothing obvious in the names as to which library has the le_pos functions.

I think you’re going to have to have a bit more of a plunder around the build directory looking for the correct library…

ciao, Dave

Thanks… I got it compiled by linking the le_pos, le_posCtrl libraries.

Hi @abinayak88,

Excellent news. Good luck with the rest of your project.

ciao, Dave