BelledonneCommunications / bctoolbox

Linphone.org mirror for bctoolbox (git://git.linphone.org/bctoolbox.git)
http://linphone.org
GNU General Public License v3.0
25 stars 33 forks source link

Fix Libs.private flags for mbedtls #4

Closed joerg-krause closed 7 years ago

joerg-krause commented 7 years ago

Static linking with bctoolbox fails when using pkg-config as the generated bctoolbox.pc file only consists of an '-L' string without any search path or libraries flags.

That's because of an typo in mbedtls_library_path. However, mbedtls_library_path contains a string of the mbedtls libraries concatenated by an ';' which cannot be parsed by pkg-config.

Therefore, use MBEDTLS_LIBRARY instead of MBEDTLS_LIBRARIES to get the library path.

Furthermore, add the three mbedtls libraries mbedtls, mbedcrypto, and mbedx509 to LIBS_PRIVATE so these libraries are added to the Libs.private field of bctoolbox.pc.

jehandelalune commented 7 years ago

Thanks for reporting us this issue. I fixed it slightly differently than your proposal. Cheers

joerg-krause commented 7 years ago

I've tested this commit. The Libs.private is now:

Libs.private:  /mnt/data/git/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/lib32/libmbedtls.a /mnt/data/git/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/lib32/libmbedx509.a /mnt/data/git/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/lib32/libmbedcrypto.a

Which is not how the link flags for the libraries should be, but it should be this way:

Libs.private:  -L/mnt/data/git/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/lib32 -lmbedtls -lmbedx509 -lmbedcrypto
joerg-krause commented 7 years ago

@jehandelalune Friendly ping...

jehandelalune commented 7 years ago

Hi Joerg,

In the case you mentioned, private libraries are exported from mbedtls which is compiled statically. I'm not a pkg-config expert, but what is wrong in putting paths to static libs in a .pc file ?

joerg-krause commented 7 years ago

You do not pass the paths to the needed libraries, but the needed libraries as linker flags to Libs.private. Please have look at an example .pc file from the pkg-config package.

Furthermore, having a look at how pkg-config parses the Libs.private field, shows that it looks for -L and -l chunks (without any suffix on Unix systems).