DarkElvenAngel
Posts: 416
Joined: Tue Mar 20, 2018 9:53 pm

Troubleshooting linked libraries

Thu Mar 26, 2020 2:02 pm

Hello everyone,

I'm hoping someone can shed some light on this, I am writing an application for use on Buildroot. But for some reason when I compile my program it's linking to a whole bunch of libraries.

ldd output

Code: Select all

	linux-vdso.so.1 (0xbef39000)
	/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb6f61000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6eca000)
	libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6e9f000)
	libcec.so.4 => /usr/lib/arm-linux-gnueabihf/libcec.so.4 (0xb6dfa000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6dd0000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6c82000)
	/lib/ld-linux-armhf.so.3 (0xb6f76000)
	libp8-platform.so.2 => /usr/lib/arm-linux-gnueabihf/libp8-platform.so.2 (0xb6c68000)
	libudev.so.1 => /lib/arm-linux-gnueabihf/libudev.so.1 (0xb6c38000)
	libXrandr.so.2 => /usr/lib/arm-linux-gnueabihf/libXrandr.so.2 (0xb6c1f000)
	libX11.so.6 => /usr/lib/arm-linux-gnueabihf/libX11.so.6 (0xb6afd000)
	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6ae6000)
	libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6ad3000)
	libvcos.so => /opt/vc/lib/libvcos.so (0xb6aba000)
	libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0xb6aa4000)
	libbcm_host.so => /opt/vc/lib/libbcm_host.so (0xb6a7a000)
	libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6933000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6906000)
	libXext.so.6 => /usr/lib/arm-linux-gnueabihf/libXext.so.6 (0xb68e7000)
	libXrender.so.1 => /usr/lib/arm-linux-gnueabihf/libXrender.so.1 (0xb68ce000)
	libxcb.so.1 => /usr/lib/arm-linux-gnueabihf/libxcb.so.1 (0xb689f000)
	libXau.so.6 => /usr/lib/arm-linux-gnueabihf/libXau.so.6 (0xb688c000)
	libXdmcp.so.6 => /usr/lib/arm-linux-gnueabihf/libXdmcp.so.6 (0xb6877000)
	libbsd.so.0 => /usr/lib/arm-linux-gnueabihf/libbsd.so.0 (0xb684f000)
I'm compiling with these LFLAGS

Code: Select all

LFLAGS = -lm -lz - pthread -lcec
How do I sort out why all these libraries are linked?

Thanks for your time.

swampdog
Posts: 340
Joined: Fri Dec 04, 2015 11:22 am

Re: Troubleshooting linked libraries

Thu Mar 26, 2020 7:49 pm

My throwaway pi is not working atm so for a guess..

Code: Select all

$ldd /usr/lib/arm-linux-gnueabihf/libcec.so.4
..and 'objdump -CT' kind of approach will reveal undefined symbols in there, will be pulling the other libs in.

Caveat. I don't use Buildroot.

User avatar
Paeryn
Posts: 2837
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Troubleshooting linked libraries

Thu Mar 26, 2020 8:31 pm

My guess would be libcec, same as swampdog I don't have it installed to check against but looking at the cmake file for libcec it will pull in Xrandr, X11, rt, vcos, vchiq_arm, bcm_host. These libraries can (will) pull in other libraries that they rely on.
She who travels light — forgot something.

DarkElvenAngel
Posts: 416
Joined: Tue Mar 20, 2018 9:53 pm

Re: Troubleshooting linked libraries

Thu Mar 26, 2020 8:31 pm

swampdog wrote:
Thu Mar 26, 2020 7:49 pm
My throwaway pi is not working atm so for a guess..

Code: Select all

$ldd /usr/lib/arm-linux-gnueabihf/libcec.so.4
..and 'objdump -CT' kind of approach will reveal undefined symbols in there, will be pulling the other libs in.

Caveat. I don't use Buildroot.
That's it! So the raspbian build is calling all this extra libraries. Since I built my libcec in buildroot as well, it doesn't link as many libraries.

Thanks Swampdog, I didn't know that ldd worked like that good to know!

DarkElvenAngel
Posts: 416
Joined: Tue Mar 20, 2018 9:53 pm

Re: Troubleshooting linked libraries

Thu Mar 26, 2020 8:34 pm

Paeryn wrote:
Thu Mar 26, 2020 8:31 pm
My guess would be libcec, same as swampdog I don't have it installed to check against but looking at the cmake file for libcec it will pull in Xrandr, X11, rt, vcos, vchiq_arm, bcm_host. These libraries can (will) pull in other libraries that they rely on.
You guessed correctly as well.

At least I know now what is going on it's now just to check if my binary will run on with a different libcec.

Return to “C/C++”