microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.27k stars 6.41k forks source link

azure-storage-cpp: Undefined symbols _llvm_gcov_init _llvm_gcda_emit_function _llvm_gcda_emit_arcs _llvm_gcda_emit_function _llvm_gcda_start_file _llvm_gcda_end_file #5761

Closed fferri closed 4 years ago

fferri commented 5 years ago

Platform: x64-osx Cmake project using azure-storage-cpp:

cmake_minimum_required(VERSION 3.5.1)
project(myProject)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt5 COMPONENTS Core Widgets NetworkAuth WebEngineWidgets REQUIRED)
find_package(Boost COMPONENTS system thread chrono filesystem log REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(cpprestsdk REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(unofficial-iconv REQUIRED)
find_path(WASTORAGE_INCLUDE_DIR was/blob.h)
find_library(WASTORAGE_LIBRARY azurestorage)

include_directories(${Boost_INCLUDE_DIRS})
include_directories(${WASTORAGE_INCLUDE_DIR})
link_libraries(Qt5::Core Qt5::Gui Qt5::Widgets Qt5::NetworkAuth Qt5::WebEngineWidgets)
link_libraries(${Boost_LIBRARIES})
link_libraries(OpenSSL::SSL OpenSSL::Crypto)
link_libraries(cpprestsdk::cpprest)
link_libraries(${LIBXML2_LIBRARIES})
link_libraries(unofficial::iconv::libiconv)
link_libraries(${WASTORAGE_LIBRARY})

add_executable(...)

I had to add a few other dependencies for azure-storage-cpp, such as cpprestsdk, libxml2, iconv, openssl, but I'm still getting these unresolved symbols:

Undefined symbols for architecture x86_64:
  "_llvm_gcda_emit_arcs", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_emit_function", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_end_file", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_start_file", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_summary_info", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
Undefined symbols for architecture x86_64:
  "_llvm_gcda_emit_arcs", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcov_init", referenced from:
      ___llvm_gcov_init in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_common.cpp.o)
  "_llvm_gcda_emit_function", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_end_file", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
ld: symbol(s) not found for architecture x86_64
  "_llvm_gcda_start_file", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_summary_info", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [BlueCloudClientTests] Error 1
make[1]: *** [CMakeFiles/BlueCloudClientTests.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
  "_llvm_gcov_init", referenced from:
      ___llvm_gcov_init in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_blob_client.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)

Perhaps similar to facebook/KVOController#65?

MVoz commented 5 years ago

not found for architecture x86_64 clang: error

use -v to see invocation

fferri commented 5 years ago
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.14.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -o BlueCloudClientTests -search_paths_first -headerpad_max_install_names CMakeFiles/BlueCloudClientTests.dir/tests.cpp.o CMakeFiles/BlueCloudClientTests.dir/client.cpp.o CMakeFiles/BlueCloudClientTests.dir/data.cpp.o CMakeFiles/BlueCloudClientTests.dir/BlueCloudClientTests_autogen/mocs_compilation.cpp.o -v /usr/local/opt/qt/lib/QtNetworkAuth.framework/QtNetworkAuth /usr/local/opt/qt/lib/QtWebEngineWidgets.framework/QtWebEngineWidgets /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_system.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_thread.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_chrono.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_filesystem.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_log.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_date_time.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_atomic.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_log_setup.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libboost_regex.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libssl.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libcrypto.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libcpprest.a /Users/me/Dev/vcpkg/installed/x64-osx/lib/libxml2.a /Users/me/Dev/vcpkg/installed/x64-osx/lib/liblzma.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libz.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libazurestorage.a /usr/local/opt/qt/lib/QtWebEngineCore.framework/QtWebEngineCore /usr/local/opt/qt/lib/QtWebChannel.framework/QtWebChannel /usr/local/opt/qt/lib/QtPositioning.framework/QtPositioning /usr/local/opt/qt/lib/QtQuick.framework/QtQuick /usr/local/opt/qt/lib/QtQml.framework/QtQml /usr/local/opt/qt/lib/QtNetwork.framework/QtNetwork /usr/local/opt/qt/lib/QtPrintSupport.framework/QtPrintSupport /usr/local/opt/qt/lib/QtWidgets.framework/QtWidgets /usr/local/opt/qt/lib/QtGui.framework/QtGui /usr/local/opt/qt/lib/QtCore.framework/QtCore /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libz.a -framework CoreFoundation -framework Security /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libssl.a /Users/me/Dev/vcpkg/installed/x64-osx/debug/lib/libcrypto.a -ldl -liconv -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/lib/darwin/libclang_rt.osx.a
@(#)PROGRAM:ld  PROJECT:ld64-409.12
BUILD 17:47:51 Sep 25 2018
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em arm64e arm64_32
Library search paths:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
  "_llvm_gcda_emit_arcs", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_emit_function", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_end_file", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_start_file", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcda_summary_info", referenced from:
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_writeout in libazurestorage.a(cloud_blob_client.cpp.o)
      ...
  "_llvm_gcov_init", referenced from:
      ___llvm_gcov_init in libazurestorage.a(cloud_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_common.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_block_blob.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(operation_context.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_blob_container.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_storage_account.cpp.o)
      ___llvm_gcov_init in libazurestorage.a(cloud_blob_client.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]: *** [BlueCloudClientTests] Error 1
make[1]: *** [CMakeFiles/BlueCloudClientTests.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
MVoz commented 5 years ago

you do not have enough symbol libraries for the specified architecture

symbol __llvm***

libraries libazurestorage.a

object cloud_***

when building add the necessary code or remove dependencies for your project links to this code

http://logan.tw/posts/2015/04/28/check-code-coverage-with-clang-and-lcov/

add --coverage option

fferri commented 5 years ago

Adding coverage flags (e.g. via add_definitions(-fprofile-arcs -ftest-coverage) and link_libraries(--coverage)) doesn't help

PhoebeHui commented 4 years ago

This issue hasn’t been updated in a year; if it is still an issue, please reopen.

chengjzh commented 2 years ago

So what's the solution for this