I am currently trying to use the vscode plugin to build my app that uses a third party .so file (sqlite to exact). I am using the ldflag command in my .cdef to include the .so. However this doesn’t seem to work and complains about undefined references.
Automated vscode build output
> Executing task: mkapp ${LEGATO_DEF_FILE} -s components -t ${LEGATO_TARGET} -w ${LEGATO_OBJECT_DIR} -o ${LEGATO_OUTPUT_DIR} <
[1/1] Regenerating build script
[6/9] Linking C executable
FAILED: /home/french/leaf/_build_SQLiteDemo/wp77xx/app/SQLiteDemo/obj/SQLiteDemoComponentExe/SQLiteDemoComponentExe
/home/french/leaf/leaf-data/dev/wp77-toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/home/french/leaf/leaf-data/dev/wp77-toolchain/sysroots/armv7a-neon-poky-linux-gnueabi -fPIE -pie -o /home/french/leaf/_build_SQLiteDemo/wp77xx/app/SQLiteDemo/obj/SQLiteDemoComponentExe/SQLiteDemoComponentExe /home/french/leaf/_build_SQLiteDemo/wp77xx/app/SQLiteDemo/obj/SQLiteDemoComponentExe/_main.c.o -rdynamic -Wl,--enable-new-dtags,-rpath="\$ORIGIN/../lib" -L "-L/home/french/leaf/_build_SQLiteDemo/wp77xx/component/652a9d5bf0d55627ce7e6178f2524356/obj" -lComponent_SQLiteDemoComponent -L /home/french/leaf/leaf-data/dev/wp77-legato/3rdParty/sqlite/lib/sqlite3.so "-L/home/french/leaf/_build_SQLiteDemo/wp77xx/component/652a9d5bf0d55627ce7e6178f2524356/obj" -lComponent_SQLiteDemoComponent -L /home/french/leaf/leaf-data/dev/wp77-legato/3rdParty/sqlite/lib/sqlite3.so "-L$LEGATO_BUILD/framework/lib" -llegato -lpthread -lrt -ldl -lm
/home/french/leaf/_build_SQLiteDemo/wp77xx/component/652a9d5bf0d55627ce7e6178f2524356/obj/libComponent_SQLiteDemoComponent.so: undefined reference to `sqlite3_libversion'
/home/french/leaf/_build_SQLiteDemo/wp77xx/component/652a9d5bf0d55627ce7e6178f2524356/obj/libComponent_SQLiteDemoComponent.so: undefined reference to `sqlite3_open'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The terminal process "/bin/bash '-c', 'mkapp ${LEGATO_DEF_FILE} -s components -t ${LEGATO_TARGET} -w ${LEGATO_OBJECT_DIR} -o ${LEGATO_OUTPUT_DIR}'" failed to launch (exit code: 1).
component.cdef
// SQLiteDemoComponent
//
// This is component definition file that specifies the internal content and external interfaces
// of reusable software components.
//
// For more details on the component definition (.cdef) file format see:
// https://docs.legato.io/latest/defFilesCdef.html
// Source code files.
sources:
{
SQLiteDemoComponent.c
}
ldflags:
{
-L ${LEGATO_ROOT}/3rdParty/sqlite/lib/sqlite3.so
}
// Bind resources from the target module into your application.
requires:
{
// IPC APIs used by this component.
api:
{
}
// File paths local to your target module.
file:
{
}
// Directories on your target module to make accessible to the app.
dir:
{
}
// Linux filesystem device paths.
device:
{
}
// Shared libraries pre-installed on the module.
lib:
{
}
}
SQLiteDemo.adef
sandboxed: false
// Specify the bundled components for your application here. This section needs to contain a list
// of system paths to your component directory.
components:
{
}
// Add the list of executables to be constructed and moved to the /bin directory of the app. The
// executable content is a list of the components inside the executable.
//
// Example binding format:
// clientExe.clientComponent.clientInterface -> serverExe.serverComponent.serverInterface
executables:
{
SQLiteDemoComponentExe = ( SQLiteDemoComponent )
}
// The processes section specifies processes to run when the app is started including environment
// variables, command-line arguments, limits, and fault handling actions.
processes:
{
run:
{
( SQLiteDemoComponentExe )
}
}
// Bindings that allow client side API interfaces to be bound to servers found within other
// applications in the system.
bindings:
{
}
bundles:
{
file:
{
[r] ${LEGATO_ROOT}/3rdParty/sqlite/lib/sqlite3.so /lib/
}
}
If I run the mkapp command manually I get a successfull build and can upload and run the .update file so I am fairly certain everyting is as it should be.
$ mkapp ${LEGATO_DEF_FILE} -s components -t ${LEGATO_TARGET} -w ${LEGATO_OBJECT_DIR} -o ${LEGATO_OUTPUT_DIR} -L ${LEGATO_ROOT}/3rdParty/sqlite/lib/sqlite3.so
[9/9] Packaging app
Am i wrong in expecting adding the -L in the cdef file will have the same effect as if I was to manually add it to the command? Or is there something I dont understand correctly.