ivanmejiarocha / micro-service

sample micro-service in C++
MIT License
263 stars 129 forks source link

Undefined symbols for architecture x86_64 #4

Closed kennethbedolla closed 6 years ago

kennethbedolla commented 6 years ago

Using: Mac OS High Sierra 10.13.6 XCode: 9.4.1

After following instructions 1-4 on the "How To Build" section in the README I get the following error when I try to run step 5.

The only changes I made were update the versions for cpprestsdk to 2.10.4 in the /build/build_dependencies.sh file and i also updated the version of OPENSSL to 1.0.2p in the cmakelists.txt file.

Undefined symbols for architecture x86_64: "_deflate", referenced from: web::http::details::compression::stream_compressor::stream_compressor_impl::compress(unsigned char const*, unsigned long, bool) in libcpprest.a(http_helpers.cpp.o) "_deflateEnd", referenced from: std::__1::__shared_ptr_emplace<web::http::details::compression::stream_compressor::stream_compressor_impl, std::__1::allocator<web::http::details::compression::stream_compressor::stream_compressor_impl> >::~__shared_ptr_emplace() in libcpprest.a(http_helpers.cpp.o) std::__1::__shared_ptr_emplace<web::http::details::compression::stream_compressor::stream_compressor_impl, std::__1::allocator<web::http::details::compression::stream_compressor::stream_compressor_impl> >::~__shared_ptr_emplace() in libcpprest.a(http_helpers.cpp.o) std::__1::__shared_ptr_emplace<web::http::details::compression::stream_compressor::stream_compressor_impl, std::__1::allocator<web::http::details::compression::stream_compressor::stream_compressor_impl> >::__on_zero_shared() in libcpprest.a(http_helpers.cpp.o) "_deflateInit2_", referenced from: std::__1::shared_ptr<web::http::details::compression::stream_compressor::stream_compressor_impl> std::__1::shared_ptr<web::http::details::compression::stream_compressor::stream_compressor_impl>::make_shared<web::http::details::compression::compression_algorithm&>(web::http::details::compression::compression_algorithm&&&) in libcpprest.a(http_helpers.cpp.o) "_deflateInit_", referenced from: std::__1::shared_ptr<web::http::details::compression::stream_compressor::stream_compressor_impl> std::__1::shared_ptr<web::http::details::compression::stream_compressor::stream_compressor_impl>::make_shared<web::http::details::compression::compression_algorithm&>(web::http::details::compression::compression_algorithm&&&) in libcpprest.a(http_helpers.cpp.o) "_inflate", referenced from: web::http::details::compression::stream_decompressor::stream_decompressor_impl::decompress(unsigned char const*, unsigned long) in libcpprest.a(http_helpers.cpp.o) "_inflateEnd", referenced from: std::__1::__shared_ptr_emplace<web::http::details::compression::stream_decompressor::stream_decompressor_impl, std::__1::allocator<web::http::details::compression::stream_decompressor::stream_decompressor_impl> >::~__shared_ptr_emplace() in libcpprest.a(http_helpers.cpp.o) std::__1::__shared_ptr_emplace<web::http::details::compression::stream_decompressor::stream_decompressor_impl, std::__1::allocator<web::http::details::compression::stream_decompressor::stream_decompressor_impl> >::~__shared_ptr_emplace() in libcpprest.a(http_helpers.cpp.o) std::__1::__shared_ptr_emplace<web::http::details::compression::stream_decompressor::stream_decompressor_impl, std::__1::allocator<web::http::details::compression::stream_decompressor::stream_decompressor_impl> >::__on_zero_shared() in libcpprest.a(http_helpers.cpp.o) "_inflateInit2_", referenced from: web::http::details::compression::stream_decompressor::stream_decompressor(web::http::details::compression::compression_algorithm) in libcpprest.a(http_helpers.cpp.o) web::http::details::compression::stream_decompressor::stream_decompressor(web::http::details::compression::compression_algorithm) in libcpprest.a(http_helpers.cpp.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [micro-service] Error 1 make[1]: *** [CMakeFiles/micro-service.dir/all] Error 2 make: *** [all] Error 2

wmash commented 6 years ago

@kennethbedolla was there ever a resolution here? I am getting the same error

ivanmejiarocha commented 6 years ago

Hi @kennethbedolla and @wmash, It seams that cpprestsdk static library latest version has a dependency on zlib, so please do the following:

$ brew install lib

then on the CMakelists.txt add the following lines:

set(ZIP_LIBRARY "/usr/local/Cellar/zlib/1.2.11/lib/libz.dylib")

set(LIBRARIES_SEARCH_PATHS ${OPENSSL_LIBS} ${Boost_LIBRARIES} ${CPPRESTSDK_LIBRARY} ${ZIP_LIBRARY})

where as you can see marked in bold you need to add ZIP_LIBRARY to the libraries search path

then build again.