Skip to content
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

Cannot use statically compiled curl[openssl] in MacOS #7260

Closed
FerzanVivec opened this issue Jul 14, 2019 · 13 comments
Closed

Cannot use statically compiled curl[openssl] in MacOS #7260

FerzanVivec opened this issue Jul 14, 2019 · 13 comments
Assignees
Labels
requires:repro The issue is not currently repro-able

Comments

@FerzanVivec
Copy link

FerzanVivec commented Jul 14, 2019

I'm trying to compile my cross-platform app. Windows version works. Mac version fails when linking. I need curl for cpr package.

Triplet:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)

package versions:

cpr:x64-osx 1.3.0-7
curl:x64-osx 7.65.0-3 A library for transferring data with URLs
curl[mbedtls]:x64-osx SSL support (mbedTLS)
curl[openssl]:x64-osx SSL support (OpenSSL)
curl[sectransp]:x64-osx SSL support (sectransp)
curl[ssl]:x64-osx Default SSL backend
openssl-unix:x64-osx 1.0.2s-1 OpenSSL is an open source project that provides ...
openssl:x64-osx 1 OpenSSL is an open source project that provides ...

vcpkg version:

2019.06.26-unknownhash

Undefined symbols for architecture x86_64: "_SecCertificateCopyLongDescription", referenced from: _CopyCertSubject in libcurl.a(sectransp.c.o) "_SSLGetNegotiatedProtocolVersion", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SecTrustCopyPublicKey", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SecTrustSetAnchorCertificates", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SecTrustSetAnchorCertificatesOnly", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SSLWrite", referenced from: _sectransp_send in libcurl.a(sectransp.c.o) "_SecTrustEvaluate", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SSLSetProtocolVersionMax", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLCopyALPNProtocols", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_kSecClass", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLSetALPNProtocols", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_kSecReturnRef", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_kSecMatchLimit", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_kSecMatchPolicy", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecItemCopyMatching", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecCertificateCreateWithData", referenced from: _append_cert_to_array in libcurl.a(sectransp.c.o) "_SSLRead", referenced from: _sectransp_recv in libcurl.a(sectransp.c.o) "_SSLSetIOFuncs", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecItemImport", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecCertificateGetTypeID", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLGetNegotiatedCipher", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SSLSetPeerDomainName", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_kSecImportItemIdentity", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecTrustGetCertificateCount", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecIdentityCreateWithCertificate", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLCreateContext", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLSetSessionOption", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLGetNumberSupportedCiphers", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_kSecAttrLabel", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLSetPeerID", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecPolicyCreateSSL", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecIdentityCopyCertificate", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLSetEnabledCiphers", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecCertificateCopyCommonName", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLSetConnection", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLGetSupportedCiphers", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLHandshake", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SecKeyCopyExternalRepresentation", referenced from: _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SSLCopyPeerTrust", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) _sectransp_connect_step2 in libcurl.a(sectransp.c.o) "_SSLSetCertificate", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SecTrustGetCertificateAtIndex", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLGetBufferedReadSize", referenced from: _Curl_sectransp_data_pending in libcurl.a(sectransp.c.o) "_kSecClassIdentity", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLClose", referenced from: _Curl_sectransp_shutdown in libcurl.a(sectransp.c.o) _Curl_sectransp_close in libcurl.a(sectransp.c.o) "_SSLSetProtocolVersionMin", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_kSecMatchLimitAll", referenced from: _sectransp_connect_common in libcurl.a(sectransp.c.o) "_SSLGetSessionState", referenced from: _Curl_sectransp_check_cxn in libcurl.a(sectransp.c.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

There was no problem when I last build it a couple of months ago.

@past-due
Copy link
Contributor

past-due commented Jul 14, 2019

Try finding CURL using:
find_package(CURL CONFIG)

This should pick up the appropriate exported CMake configuration for CURL, including everything required to link successfully.

(It's possible that the cpr port may require a patch to change find_package(CURL) to find_package(CURL CONFIG).)

@Toxe
Copy link
Contributor

Toxe commented Jul 19, 2019

@FerzanVivec Were you able to resolve this? Because I have similar problems with cpr and curl.

@FerzanVivec
Copy link
Author

@FerzanVivec Were you able to resolve this? Because I have similar problems with cpr and curl.

I just rolled back vcpkg to a March version (can't remember which) and my app compiled fine.

@Toxe
Copy link
Contributor

Toxe commented Jul 19, 2019

I just rolled back vcpkg to a March version (can't remember which) and my app compiled fine.

Ah, I see. Maybe I should try that and see what the changes were.

@past-due
Copy link
Contributor

To amend my earlier post, you will need to both use find_package CONFIG mode, and link to the defined target.

find_package(CURL CONFIG REQUIRED)
target_link_libraries(main PRIVATE CURL::libcurl)

This is instead of using the old ${CURL_LIBRARIES} and ${CURL_INCLUDE_DIRS} variables.

@Toxe
Copy link
Contributor

Toxe commented Jul 19, 2019

Thanks, I will give that a try.

Just opened a new issue here: #7332

@Toxe
Copy link
Contributor

Toxe commented Jul 19, 2019

Nice, this did indeed work! Thanks a lot!

@Deadpikle
Copy link
Contributor

I'm unaware of the internals of how cmake works in terms of this bugfix, but when attempting to link to libcurl.a in Xcode and receiving the same linker errors, you can resolve these linker issues by also linking to Security.framework from Xcode's "Linked Frameworks and Libraries" section. I'm not sure if the above CMakeLists.txt change would remove the need to do that manual link in Xcode.

(Also posting this same comment in the linked issue by Toxe in case someone stumbles here from Google like me so they can have a temp fix before the PR comes through.)

@NancyLi1013
Copy link
Contributor

Hi all.

Currently, I cannot reproduce this on my machine with the following usage:

    find_package(CURL CONFIG REQUIRED)
    target_link_libraries(main PRIVATE CURL::libcurl)

Please open a new issue or provide the repro steps and your project case if this is still a problem for you.

@NancyLi1013 NancyLi1013 added the requires:repro The issue is not currently repro-able label Nov 3, 2020
@danoli3
Copy link

danoli3 commented Jan 26, 2022

Yeah just add Security.framework to fix this

@dg0yt
Copy link
Contributor

dg0yt commented Jan 26, 2022

Yeah just add Security.framework to fix this

Is it missing with cmake or pkg-config? Port curl has received significant work since this issue was closed more than one year ago.

@2018DHY
Copy link

2018DHY commented Mar 23, 2022

I use macos10.15.7 also.when I use g++ -lpath/to/vcpkg/lib/libcurl.a,it have the same error like above.but when i use the /usr/lib/libcurl.4.dylib,the error is gone,i don't konw why,but it is a solution.

@dg0yt
Copy link
Contributor

dg0yt commented Mar 23, 2022

@2018DHY curl:x64-osx builds a static library. (x64-osx is static by default.) So you have to take care of transitive usage requirements. That's why you should use CMake package information or pkg-config.
OTOH libcurl.4.dylib is a shared library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires:repro The issue is not currently repro-able
Projects
None yet
Development

No branches or pull requests

8 participants