Skip to content

libcpprestsdk: fix building as a static library #1344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2020
Merged

libcpprestsdk: fix building as a static library #1344

merged 1 commit into from
Mar 2, 2020

Conversation

ffontaine
Copy link
Contributor

On Unix, try to use pkg-config to find OpenSSL. This will automatically
find any dependent libraries and put them in the correct order for
linking. If pkg-config is not available or system is not UNIX, fallback
on current mechanism

Signed-off-by: Adam Duskett [email protected]
[Retrieved (and slightly updated) from:
https://git.buildroot.net/buildroot/tree/package/libcpprestsdk/0001-libcpprestsdk-fix-building-as-a-static-library.patch]
Signed-off-by: Fabrice Fontaine [email protected]

On Unix, try to use pkg-config to find OpenSSL. This will automatically
find any dependent libraries and put them in the correct order for
linking. If pkg-config is not available or system is not UNIX, fallback
on current mechanism

Signed-off-by: Adam Duskett <[email protected]>
[Retrieved (and slightly updated) from:
https://git.buildroot.net/buildroot/tree/package/libcpprestsdk/0001-libcpprestsdk-fix-building-as-a-static-library.patch]
Signed-off-by: Fabrice Fontaine <[email protected]>
@ffontaine
Copy link
Contributor Author

This is a new tentative following #1026, I'll try to fix all issues this time to get it merged.

Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@BillyONeal BillyONeal merged commit cb7ca74 into microsoft:master Mar 2, 2020
c72578 added a commit to c72578/cpprestsdk that referenced this pull request Apr 28, 2020
…)"

This reverts commit cb7ca74.

Issues concerning linking (microsoft#1388) and cross compiling (microsoft#1378) have
been reported.

- Fixes microsoft#1388
@c72578
Copy link
Contributor

c72578 commented Apr 28, 2020

@ffontaine could you please describe in detail, under which conditions "building as a static library" fails, so that it can be reproduced? Including OS and versions of involved packages. Which error do you get?

So far, I do not see any problems, when building cpprestsdk as a static library:

cd Release
mkdir build
cd build
cmake -G Ninja .. -DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Release -DWERROR=OFF
ninja
cd Binaries
./test_runner

All test cases PASSED
Finished running all 783 tests.

OK, no problems detected

Tested under:

OS: Linux, Fedora 31 x86_64
cpprestsdk: v2.10.15 (which is just before the commit from this PR here)
cmake: 3.17.1
ninja-build: 1.9.0
openssl: 1.1.1d
pkgconf: 1.6.3

@c72578
Copy link
Contributor

c72578 commented May 2, 2020

@aduskett could you please describe in detail, under which conditions "building as a static library" fails, so that it can be reproduced? Including OS and versions of involved packages. Which error do you get?

@ffontaine
Copy link
Contributor Author

Build failure was raised on buildroot with version 2.10.1 using BR2_STATIC_LIBS=y which means that all packages including openssl will be built statically by buildroot, full debug log can be found here: http://autobuild.buildroot.net/results/be9e8d1717968a0ff8f01f7fadfa79825ac88b94/build-end.log, especially:

[ 89%] Linking CXX executable ../../../Binaries/blackjackclient
/accts/mlweber1/instance-2/output/host/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
c_zlib.c:(.text+0x7c): undefined reference to `inflate'
c_zlib.c:(.text+0x84): undefined reference to `inflate'
/accts/mlweber1/instance-2/output/host/mips64el-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
c_zlib.c:(.text+0x13c): undefined reference to `deflate'
c_zlib.c:(.text+0x144): undefined reference to `deflate'

I'm able to reproduce he build failure locally with version 2.10.5 (without this patch).

I assume that if you're building on Fedora or any other "standard" OS, you'll not encounter this issue as the libssl-dev package will always install both libcrypto.so and libcrypto.a.

c72578 added a commit to c72578/cpprestsdk that referenced this pull request May 2, 2020
…)"

This reverts commit cb7ca74.

Issues concerning OpenSSL dependency and linking (microsoft#1384, microsoft#1388)
and cross compiling (microsoft#1378) have been reported.

- Fixes microsoft#1384, microsoft#1388
c72578 added a commit to c72578/cpprestsdk that referenced this pull request May 2, 2020
…)"

This reverts commit cb7ca74.

Issues concerning OpenSSL linking dependency (microsoft#1384, microsoft#1388)
and cross compiling (microsoft#1378) have been reported.

- Fixes microsoft#1384, microsoft#1388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants