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

clang++ link asbl lib failed #21904

Open
6 of 7 tasks
WittonBell opened this issue Sep 12, 2024 · 4 comments
Open
6 of 7 tasks

clang++ link asbl lib failed #21904

WittonBell opened this issue Sep 12, 2024 · 4 comments
Labels

Comments

@WittonBell
Copy link

WittonBell commented Sep 12, 2024

Description / Steps to reproduce the issue

  1. create main.cpp:
#include <absl/log/log.h>

int main(int, char**){
    LOG(INFO) << (unsigned long long)1;
}
  1. create `CMakeLists.txt":
cmake_minimum_required(VERSION 3.5.0)
project(t VERSION 0.1.0 LANGUAGES C CXX)

find_package(absl REQUIRED)
add_executable(t main.cpp)
target_link_libraries(t PUBLIC absl_log_internal_message)
  1. run cmake -DCMAKE_CXX_COMPILER=clang++ . in mingw64 terminal
  2. run cmake --build .
    it report:
ld: CMakeFiles/t.dir/main.cpp.obj:main.cpp:(.text$_ZN4absl12lts_2024072212log_internal10LogMessagelsEy[_ZN4absl12lts_2024072212log_internal10LogMessagelsEy]+0x19): undefined reference to `_ZN4absl12lts_2024072212log_internal10LogMessagelsIyTnNSt9ena
ble_ifIXntsr4absl16HasAbslStringifyIT_EE5valueEiE4typeELi0EEERS2_RKS5_

btw: use g++ build success.

Expected behavior

build success.

Actual behavior

build failed

Verification

Windows Version

MINGW64_NT-10.0-19045

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANG32
  • CLANGARM64

Are you willing to submit a PR?

No response

@WittonBell WittonBell added the bug label Sep 12, 2024
@Biswa96
Copy link
Member

Biswa96 commented Sep 12, 2024

If I use clang++ in clang64 environment the program compiles fine. Probably, there are some difference in abseil-cpp package in gcc and clang based environment.

@oltolm
Copy link
Contributor

oltolm commented Sep 12, 2024

You can also try adding -fuse-ld=lld to link options and -stdlib=libc++ to compile options.

@WittonBell
Copy link
Author

WittonBell commented Sep 14, 2024

You can also try adding -fuse-ld=lld to link options and -stdlib=libc++ to compile options.

@oltolm It does not take effect, also has the issue.

@oltolm
Copy link
Contributor

oltolm commented Sep 14, 2024

Then the mingw64 version is not binary compatible with clang and you should use the clang64 environment like Biswa96 said.

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

3 participants