Build failing on link step

Hello all,

I’m having issues getting my MangOH Red project to build. Our main repository for this project is closed source, however I’ve opened a public repository with a minimal example showing the code for the problem we’re experiencing at

https://github.com/nvandoorn/photo-example

The build runs fine until the link step (ld). It shows the following error:

[109/969] Linking C executable
FAILED: /opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y17-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi -o /home/nick/Documents/BRNKL_MangOH/_build_mangOH_Red/wp85/app/photoToCloud/staging/read-only/bin/photoToCloud /home/nick/Documents/BRNKL_MangOH/_build_mangOH_Red/wp85/app/photoToCloud/obj/photoToCloud/_main.c.o -rdynamic -Wl,--enable-new-dtags,-rpath="\$ORIGIN/../lib" -L "-L_build_mangOH_Red/wp85/component/c868813a525895d00b59e88d47a4d728/obj" -lComponent_takePhoto "-L_build_mangOH_Red/wp85/component/cf4c7f083934b7856d1cdbe68482fbf2/obj" -lComponent_camera "-L_build_mangOH_Red/wp85/component/c868813a525895d00b59e88d47a4d728/obj" -lComponent_takePhoto "-L_build_mangOH_Red/wp85/component/cf4c7f083934b7856d1cdbe68482fbf2/obj" -lComponent_camera "-L$LEGATO_BUILD/framework/lib" -llegato -lpthread -lrt -ldl -lm
_build_mangOH_Red/wp85/component/c868813a525895d00b59e88d47a4d728/obj/libComponent_takePhoto.so: undefined reference to `reset'
_build_mangOH_Red/wp85/component/c868813a525895d00b59e88d47a4d728/obj/libComponent_takePhoto.so: undefined reference to `openCameraFd'
_build_mangOH_Red/wp85/component/c868813a525895d00b59e88d47a4d728/obj/libComponent_takePhoto.so: undefined reference to `snapshotToFile'
collect2: error: ld returned 1 exit status

I suspect I don’t have the .sdef/.adef/.cdef files setup quite right though I tried to mimic the style shown here.
https://github.com/mangOH/RedSensorToCloud/

Any help is greatly appreciated.

Cheers,
Nick

@asyal @dfrey We are trying to hack away on this today, if you guys have any insight we would appreciate it!

Thanks for providing an example. I will take a look.

Patches attached. There were really two main things:

  1. mksys builds C files in such a way that symbols are hidden by default. As a result, you need to mark the functions that are called between two components as LE_SHARED. This is necessary because you’re using the low-level “requires component” method of having one component call the other.
  2. When one component requires the other in this way, you only need to mention the upper component in the adef.

I didn’t try to install or run the system, but it builds now.

photo-example-0001-Remove-missing-apps-from-mangOH_Red.sdef.patch (759 Bytes)
VC0706-cam-lib-legato-0001-Fix-linker-error-by-marking-functions-LE_SHARED.patch (3.7 KB)
photo-example-0002-Fix-linker-errors.patch (1.1 KB)

Thanks for the excellent support @dfrey. I’ll give this a go tomorrow and report back.

Worked like a charm. Thanks again @dfrey.