Libsocketcan.so.2: cannot open shared object file

Hi,
I’m trying to install libsocketcan package in TorizonC/C++ project inside a container for in Colibri-imx7-1GO, to use SocketCAN APIs.
I added
devpackages : libsocketcan-dev:#%platform.debian-arch%#
extrapackage : libsocketcan2
In the Makefile, I added -lsocketcan to generate the lib ($(CC) -o $@ $^ $(CFLAGS) -lsocketcan)

After re-building the container and trying to execute the output file in the target device, I got this error:

./can-test: error while loading shared libraries: libsocketcan.so.2: cannot open shared object file: No such file or directory

is there anything else to add ?

Thanks in advance.

Greetings @Achref,

First of all before we make any assumptions can you check whether the error message is accurate or not?

You can get a shell into the container by running this on the device while the container is running, docker exec -it <container ID/name> bash. Then you can manually check if libsocketcan.so.2 file really does not exist.

Best Regards,
Jeremias

Greetings @jeremias.tx
Thanks for the reply,
yes, I already checked and I found it under /usr/lib/arm-linux-gnueabihf

Best regards

Hi @Achref !

Still from within the container, could you please run ldd <can-executable> and share the output?

Best regards,

Hi @henrique.tx
I hope that you are well
I have this problem,
When I executed it inside the container, I got the following output:

torizon@2b8660814812:/can-test$ ldd can-test 
        linux-vdso.so.1 (0xbea9c000)
        libsocketcan.so.2 => /usr/lib/arm-linux-gnueabihf/libsocketcan.so.2 (0xb6f9d000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e9e000)
        /lib/ld-linux-armhf.so.3 (0xb6fc2000)

but When executing it in the target device, the libsocketcan.so.2 not found

torizon@colibri-imx7-emmc-14866722:~/can-test$ ldd can-test 
        linux-vdso.so.1 (0xbef72000)
        libsocketcan.so.2 => not found
        libc.so.6 => /usr/lib/libc.so.6 (0xb6e61000)
        /lib/ld-linux-armhf.so.3 => /usr/lib/ld-linux-armhf.so.3 (0xb6f66000)

Thanks

Wait are you executing can-test inside the container? Or how are you executing it exactly? You mentioned that the container was created using our IDE extension is the IDE extension not executing the container/application?

The libraries and packages outside of the container are irrelevant since the application is meant to be executing in the context of the container.

Best Regards,
Jeremias

Hello @Achref
Do you have any updates on the topic?

Best regards,
Josep

Hi @josep.tx
Sorry for the late reply, I don’t have any update because I keep it in pending status and I switched to other project.
Thanks