curlcpp icon indicating copy to clipboard operation
curlcpp copied to clipboard

Do not hardcode C++ runtime library on Darwin

Open barracuda156 opened this issue 2 months ago • 1 comments

This is either redundant or breaking: https://github.com/JosephP91/curlcpp/blob/fb07bb742b77b7ad8ed7176dbf1c6e82dd2e011e/src/CMakeLists.txt#L99-L101

If a compiler does not know which C++ runtime to use, that should be fixed with compiler, not here. AFAIK, neither modern gcc nor modern clang has this issue. If a package manager uses non-default C++ runtime, it should pass the flag to handle it accordingly (MacPorts can do that).

Hardcoding just breaks the build, whenever libstdc++ should be used and not libc++:

[ 92%] Building CXX object src/CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o
cd /opt/local/var/macports/build/curlcpp-db727ff1/work/build/src && /opt/local/bin/g++-mp-14 -Dcurlcpp_EXPORTS -I/opt/local/var/macports/build/curlcpp-db727ff1/work/curlcpp-fb07bb742b77b7ad8ed7176dbf1c6e82dd2e011e/src/../include -isystem /opt/local/include -pipe -Os -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -mmacosx-version-min=10.6 -fPIC -Wall -Wextra -Wpedantic -stdlib=libc++ -MD -MT src/CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o -MF CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o.d -o CMakeFiles/curlcpp.dir/cookie_datetime.cpp.o -c /opt/local/var/macports/build/curlcpp-db727ff1/work/curlcpp-fb07bb742b77b7ad8ed7176dbf1c6e82dd2e011e/src/cookie_datetime.cpp
[100%] Linking CXX shared library libcurlcpp.dylib
cd /opt/local/var/macports/build/curlcpp-db727ff1/work/build/src && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/curlcpp.dir/link.txt --verbose=ON
Undefined symbols for architecture ppc:
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const", referenced from:
      curl::cookie::set_secure(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in cookie.cpp.o
  "std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
      __ZNSt3__16vectorINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS4_IS6_EEE21__push_back_slow_pathIRKS6_EEvOT_ in curl_cookie.cpp.o
      curl::curl_exception::get_traceback() in curl_exception.cpp.o
. . .

Also gcc supports this flag only since 10.x, and even current release may be built without support for this flag being enabled. In that case the build will fail due to unsupported flag.

barracuda156 avatar Dec 07 '25 07:12 barracuda156

Hello @barracuda156! Would be great if you could open a PR for this :)

JosephP91 avatar Dec 08 '25 09:12 JosephP91