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

drogon redis link error #2819

Closed
tashcan opened this issue Nov 10, 2023 · 1 comment
Closed

drogon redis link error #2819

tashcan opened this issue Nov 10, 2023 · 1 comment
Labels

Comments

@tashcan
Copy link
Contributor

tashcan commented Nov 10, 2023

Xmake Version

2.8.5

Operating System Version and Architecture

macOS 14.1

Describe Bug

At least on Mac, when adding drogon as a package it fails with the following error:


ld: Undefined symbols:
  _redisAsyncConnect, referenced from:
      drogon::nosql::RedisConnection::startConnectionInLoop() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncDisconnect, referenced from:
      drogon::nosql::RedisConnection::~RedisConnection() in libdrogon.a[46](RedisClientImpl.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::disconnect()::$_6, std::__1::allocator<drogon::nosql::RedisConnection::disconnect()::$_6>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncFormattedCommand, referenced from:
      drogon::nosql::RedisConnection::sendCommandInLoop(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::function<void (drogon::nosql::RedisResult const&)>&&, std::__1::function<void (drogon::nosql::RedisException const&)>&&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendSubscribeInLoop(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendUnsubscribeInLoop(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendUnsubscribeInLoop(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8, std::__1::allocator<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8, std::__1::allocator<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
      ...
  _redisAsyncHandleRead, referenced from:
      drogon::nosql::RedisConnection::handleRedisRead() in libdrogon.a[49](RedisConnection.cc.o)```


### Expected Behavior

Expect drogon to build and link without error,

### Project Configuration

```lua
set_languages("c++20")

add_requires("drogon")

target("drogon-test", function()
    set_kind("binary")
    add_files("main.cc")
    add_packages("drogon")
end)

Additional Information and Error Logs

It looks like drogon finds hiredis installed in home-brew but doesn't pass the library to the link command.
I was able to fix it by adding hiredis as a dependency to the drogon package in Xmake.

-- The CXX compiler identification is AppleClang 15.0.0.15000040
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- compiler: AppleClang
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Looking for C++ include any
-- Looking for C++ include any - found
-- Looking for C++ include string_view
-- Looking for C++ include string_view - found
-- Looking for C++ include coroutine
-- Looking for C++ include coroutine - found
-- Found OpenSSL: /opt/homebrew/Cellar/openssl@3/3.1.4/lib/libcrypto.dylib (found version "3.1.4")  
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - found
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success
-- Found std::filesystem
-- use c++20
-- Found Jsoncpp: /Users/alex/.xmake/packages/j/jsoncpp/1.9.5/68f00adf91b34ccca04c066e48dd4e43/include  
-- jsoncpp verson:1.9.5
-- Found UUID: /opt/homebrew/Cellar/ossp-uuid/1.6.2_2/lib/libuuid.dylib
-- Found Brotli: /opt/homebrew/Cellar/brotli/1.0.9/lib/libbrotlidec.dylib  
-- Brotli found
-- Found Hiredis: /opt/homebrew/lib/libhiredis.dylib  
-- Found ZLIB: /opt/homebrew/opt/zlib/lib/libz.dylib (found version "1.3")
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o /var/folders/wf/rvvs7pwn77161y6p9csqxlsh0000gn/T/.xmake501/231110/_48A91C488AEA4700813D480FA635DA30.b /var/folders/wf/rvvs7pwn77161y6p9csqxlsh0000gn/T/.xmake501/231110/_48A91C488AEA4700813D480FA635DA30.o -target arm64-apple-macos14.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -stdlib=libc++ -R/opt/homebrew/Cellar/brotli/1.0.9/lib -L/Users/alex/.xmake/packages/d/drogon/v1.8.2/ab1d3553b7b44849aef5a4fb6c69c3cb/lib -L/Users/alex/.xmake/packages/t/trantor/v1.5.14/a7c0c8fb972449efb9a1f9ea612ae626/lib -L/opt/homebrew/Cellar/c-ares/1.19.1/lib -L/Users/alex/.xmake/packages/j/jsoncpp/1.9.5/68f00adf91b34ccca04c066e48dd4e43/lib -L/opt/homebrew/Cellar/brotli/1.0.9/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/Cellar/ossp-uuid/1.6.2_2/lib -L/opt/homebrew/Cellar/openssl@3/3.1.4/lib -ldrogon -ltrantor -lcares.2.6.1 -ljsoncpp -lbrotlidec -lbrotlienc -lbrotlicommon -lz -luuid -lssl -lcrypto
ld: Undefined symbols:
  _redisAsyncConnect, referenced from:
      drogon::nosql::RedisConnection::startConnectionInLoop() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncDisconnect, referenced from:
      drogon::nosql::RedisConnection::~RedisConnection() in libdrogon.a[46](RedisClientImpl.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::disconnect()::$_6, std::__1::allocator<drogon::nosql::RedisConnection::disconnect()::$_6>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncFormattedCommand, referenced from:
      drogon::nosql::RedisConnection::sendCommandInLoop(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::function<void (drogon::nosql::RedisResult const&)>&&, std::__1::function<void (drogon::nosql::RedisException const&)>&&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendSubscribeInLoop(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendUnsubscribeInLoop(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      drogon::nosql::RedisConnection::sendUnsubscribeInLoop(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&) in libdrogon.a[49](RedisConnection.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8, std::__1::allocator<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8, std::__1::allocator<drogon::nosql::RedisConnection::sendUnsubscribe(std::__1::shared_ptr<drogon::nosql::SubscribeContext> const&)::$_8>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
      ...
  _redisAsyncHandleRead, referenced from:
      drogon::nosql::RedisConnection::handleRedisRead() in libdrogon.a[49](RedisConnection.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::startConnectionInLoop()::$_1, std::__1::allocator<drogon::nosql::RedisConnection::startConnectionInLoop()::$_1>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncHandleWrite, referenced from:
      drogon::nosql::RedisConnection::handleRedisWrite() in libdrogon.a[49](RedisConnection.cc.o)
      std::__1::__function::__func<drogon::nosql::RedisConnection::startConnectionInLoop()::$_2, std::__1::allocator<drogon::nosql::RedisConnection::startConnectionInLoop()::$_2>, void ()>::operator()() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncSetConnectCallback, referenced from:
      drogon::nosql::RedisConnection::startConnectionInLoop() in libdrogon.a[49](RedisConnection.cc.o)
  _redisAsyncSetDisconnectCallback, referenced from:
      drogon::nosql::RedisConnection::startConnectionInLoop() in libdrogon.a[49](RedisConnection.cc.o)
  _redisvFormatCommand, referenced from:
      drogon::nosql::RedisConnection::getFormattedCommand(std::__1::basic_string_view<char, std::__1::char_traits<char>> const&, char*) in libdrogon.a[46](RedisClientImpl.cc.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)```
@tashcan tashcan added the bug label Nov 10, 2023
@waruqi
Copy link
Member

waruqi commented Nov 11, 2023

you can try to open a pr to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants