Compiling to specific glibc version with mkapp

I am trying to implement a json-c library as an application and I have a problem with the glibc version.
This is the toolchain I am using for the wp77xx (FX30S)
/opt/swi/SWI9X06Y_02.32.02.00/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi

This is instead the repo for the json-c library:

The problem I have is that I can make the app and to upload it to the target, but then it doesn`t run because it requests a newer version of GLIBC 2.25 while I have a 2.24 uploaded in the target.
Sorry if this is a silly question, but I have been looking into this for the whole day trying to link the older version of the GLIBC library, but is this set by the toolchain or by the json-c library? Anyone knows where the version of the GLIBC gets assigned? Because I would expect the toolchain to compile using the suitable GLIBC library…

you can try with Ubuntu 18.04:

owner@ubuntu:~$ ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
owner@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu Bionic Beaver (development branch)
Release: 18.04
Codename: bionic
owner@ubuntu:~$

I am using ubuntu 20 on a VM but…
*****@****-VirtualBox:~/mySystemAws$ ldd --version
ldd (Ubuntu GLIBC 2.31-0ubuntu9) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

So the GLIBC version in my VM is 2.31 but the code is compiled for 2.25, this is why I was wondering if this is set somewhere (maybe in automatic) but the compiler once it compiles the files…

this is the error I get when trying to run the application:
Aug 21 07:47:44 fx30s user.err Legato: =ERR= | handleJSON[5079] | handleJSON: /lib/libc.so.6: version `GLIBC_2.25’ not found (required by /lib/libComponent_handleJSONComponent.so)

and I am assuming this is set somewhere by the toolchain not the VM machine toolchain or I would get an error saying that the version GLIBC_2.31 is required not the 2.25, correct.
The toolchain must set the required GLIBC library as it compiles the json-c library, because I don`t get this message when I compile and deploy the app I have generated for connecting to AWS.

So my question was, how can I get the toolchain to compile the app to a specific GLIBC verstion? (2.24)

do you think you can downgrade your GLIBC to have a try?

you mean to downgrade the GLIBC of ubuntu 20.04 from 2,31 to 2,24?

downgrading the glibc is a quite dangerous task, that also means that I cannot use a newer OS to compile code for an older target, which basically goes against the whole purpose of cross compiling…
Did I understand correctly what you have asked me to do?
Are you sure this is the problem?

what is the GLIBC version on your target?
On my side with FX30 FX9.1:
root@fx30:~# strings /legato/systems/current/appsWriteable/hello1/lib/libc.so.6
| grep GLIBC
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_PRIVATE

I have also tried to find the lib version inside the toolchain of WP76 R13:
owner@owner-ThinkPad-X220:/opt/swi/SWI9X07Y_02.28.03.01$ strings ./sysroots/armv7a-neon-poky-linux-gnueabi/lib/libc.so.6 | grep GLIB
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_PRIVATE

Not sure if you can find a more updated WP77 toolchain to compile your app.

(Or you can take the one in WP76 R13 toolchain and paste to the target /lib/libc.so.6?)
As /lib is read-only, you might need to overlay it:
root@fx30:~# mkdir /tmp/tmp_lib;mkdir /tmp/tmp_lib_wr;
root@fx30:~# mount -t overlay overlay /lib -o lowerdir=/lib,upperdir=/tmp/tmp_li
b,workdir=/tmp/tmp_lib_wr;

I don`t know what is included in the image for this fs, but when I make the folders and copy the libc.so.6 into the tmp_lib, then run the overlay command I get this error:

root@fx30s:/tmp# mount -t overlay overlay /lib -o lowerdir=/lib,upperdir=/tmp/tmp_lib,workdir=/tmp/tmp_lib_wr;
root@fx30s:/tmp# app start handleJSON
app: relocation error: /lib/libc.so.6: symbol _dl_exception_create, version GLIBC_PRIVATE not defined in file ld-linux.so.3 with link time reference

maybe you also need to copy the ld-linux.so.3:

owner@owner-ThinkPad-X220:~/Downloads$ find /opt/swi/SWI9X07Y_02.28.03.01/sysroots/armv7a-neon-poky-linux-gnueabi/ -name “ld-linux.so.3”
/opt/swi/SWI9X07Y_02.28.03.01/sysroots/armv7a-neon-poky-linux-gnueabi/lib/ld-linux.so.3

owner@owner-ThinkPad-X220:~/Downloads$ strings /opt/swi/SWI9X07Y_02.28.03.01/sysroots/armv7a-neon-poky-linux-gnueabi/lib/ld-linux.so.3 | grep GLIB
GLIBC_2.4
GLIBC_PRIVATE
GLIBC_TUNABLES

mmmhhh…
It doesnt seems we are getting anywhere here, maybe the best option at this point is to rebuild the image of my target with all necessary libraries, which I would have preferred to do at a later stage but I dont see any alternative if I want to move forward…

To me, no idea why your /lib/libComponent_handleJSONComponent.so will require a GLIBC lib that is not present on your toolchain.
I wonder if you are using the correct toolchain path to compile your app…

Anyway, good luck!

well, I don`t know either, this was the reason why I posted on this forum… :slight_smile:
The problem is certainly the toolchain, which is building the app with a newer Glibc library then what is included in the firmware.
The only toolchain I can find is the one from this link:
https://source.sierrawireless.com/resources/airprime/software/wp77xx/wp77xx-firmware-latest-release-components/#sthash.AFozzBQj.dpbs
poky-swi-ext-glibc-x86_64-meta-toolchain-swi-armv7a-neon-toolchain-swi-SWI9X06Y_02.35.02.00.sh

you said this should be the correct one instead:
wp77-toolchain_SWI9X06Y_02.18.05.00-linux64

So where can I find this toolchain…???

you can search by “leaf search” and then you will see a identifier "swi-fx30-catm_1.0.0 "

that is the firmware not the toolchain, correct?

it includes the toolchain, legato framework, images.

I have been working with a manual installation of the legato workspace and that could have been the problem, I was more looking to replace and re-install the toolchain still working merely under legato but I can use leaf instead.

The problem I have is that after installing the leaf:
XXXX@XXXX-VirtualBox:~/leaf/AwsProject$ leaf status
┌─────────────────────────────────────────────────────────────────────────────────────────┐
│ Workspace: /home/XXXX/leaf/AwsProject │
╞═════════════════════════════════════════════════════════════════════════════════════════╡
│ Profile: FX30S_stable [current] (sync) │
├──────────┬─────────────────────┬────────────────────────────────────────────────────────┤
│ Packages │ Identifier │ Description │
├──────────┼─────────────────────┼────────────────────────────────────────────────────────┤
│ Included │ swi-fx30-catm_1.0.0 │ SDK for FX30-CATM (Release 9.1.1.013 + Legato 18.06.1) │
└──────────┴─────────────────────┴─────────────────────

I still don`t have access to the commands (mkapp, mksys) which I get if I configure the environment under legato workspace:
XXXX@XXXX-VirtualBox:~/legatoWorkspace/legatoAF$ source bin/configlegatoenv
which should technically use the installed toolchain…

So my question is, do I need to remove the currently installed toolchain I have manually installed when using leaf or this will adjust to the required toolchain? (I would expect the former but something is not working at the moment).

you can type “export” to check if the toolchain path is correct after you do “. bin/configlegatoenv”

e.g.

this is what I read once I have setup the leaf under the leaf workspace (which is different from the legato workspace) and then run the source bin/configlegatoenv in the legato workspace.

declare -x WP77XX_KERNELROOT=“/opt/swi/SWI9X07Y_02.28.03.05/sysroots/armv7a-neon-poky-linux-gnueabi/usr/src/kernel”
declare -x WP77XX_SYSROOT=“/opt/swi/SWI9X07Y_02.28.03.05/sysroots/armv7a-neon-poky-linux-gnueabi”
declare -x WP77XX_TOOLCHAIN_DIR=“/opt/swi/SWI9X07Y_02.28.03.05/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi”
declare -x WP77XX_TOOLCHAIN_PREFIX=“arm-poky-linux-gnueabi-”

the bin folder is installed by the toolchain manual install so something is still not clear.

seems it is not using the toolchain you installed.