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

abseil link错误 #1531

Closed
qycyfjy opened this issue Oct 14, 2022 · 8 comments
Closed

abseil link错误 #1531

qycyfjy opened this issue Oct 14, 2022 · 8 comments
Labels

Comments

@qycyfjy
Copy link
Contributor

qycyfjy commented Oct 14, 2022

Xmake 版本

2.7.2+202210122221

操作系统版本和架构

Linux MFK 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

描述问题

引用abseil包,链接失败,我试了"abseil 20220623.0"和"abseil master"都有这个问题, debug下也是同样的错误,cmake正常

图片

期待的结果

链接成功

工程配置

No response

附加信息和错误日志

fde9@MFK:~/testabseil$ xmake -vD
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(dmd --version), No such file or directory
checking for dmd ... no
checkinfo: cannot runv(ldc2 --version), No such file or directory
checking for ldc2 ... no
checkinfo: cannot runv(gdc --version), No such file or directory
checking for gdc ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
/usr/bin/git rev-parse HEAD
checking for cmake ... /usr/bin/cmake
checking for cmake ... /usr/bin/cmake
finding abseil from xmake ..
checking for xmake::abseil ... abseil master
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
> gcc "-fPIC"
checking for flags (-fvisibility-inlines-hidden) ... ok
> gcc "-fvisibility-inlines-hidden"
checking for flags (-O3) ... ok
> gcc "-O3"
checking for flags (-DNDEBUG) ... ok
> gcc "-DNDEBUG"
[ 25%]: cache compiling.release src/main.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -isystem /home/fde9/.xmake/packages/a/abseil/master/4e0143c97b65425b855ad5fd03038b6a/include -DNDEBUG -o build/.objs/abseilxmake/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
> gcc "-MMD" "-MF" "/dev/null"
checking for flags (-fdiagnostics-color=always) ... ok
> gcc "-fdiagnostics-color=always"
checking for g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
checking for /usr/bin/g++ ... ok
checking for flags (-fPIC) ... ok
> g++ "-fPIC"
[ 50%]: linking.release abseilxmake
/usr/bin/g++ -o build/linux/x86_64/release/abseilxmake build/.objs/abseilxmake/linux/x86_64/release/src/main.cpp.o -m64 -L/home/fde9/.xmake/packages/a/abseil/master/4e0143c97b65425b855ad5fd03038b6a/lib -s -labsl_random_internal_distribution_test_util -labsl_synchronization -labsl_log_severity -labsl_flags_parse -labsl_hash -labsl_leak_check -labsl_status -labsl_strerror -labsl_flags_commandlineflag -labsl_cord_internal -labsl_cord -labsl_raw_logging_internal -labsl_random_seed_gen_exception -labsl_log_internal_check_op -labsl_flags_program_name -labsl_low_level_hash -labsl_demangle_internal -labsl_cordz_sample_token -labsl_flags_usage_internal -labsl_log_internal_message -labsl_periodic_sampler -labsl_spinlock_wait -labsl_flags_reflection -labsl_log_internal_log_sink_set -labsl_random_internal_randen -labsl_log_flags -labsl_raw_hash_set -labsl_random_internal_pool_urbg -labsl_die_if_null -labsl_str_format_internal -labsl_random_internal_seed_material -labsl_examine_stack -labsl_malloc_internal -labsl_scoped_set_env -labsl_strings -labsl_base -labsl_bad_variant_access -labsl_flags_config -labsl_debugging_internal -labsl_flags_internal -labsl_civil_time -labsl_log_internal_globals -labsl_int128 -labsl_statusor -labsl_strings_internal -labsl_log_internal_format -labsl_time_zone -labsl_random_seed_sequences -labsl_flags_commandlineflag_internal -labsl_flags_marshalling -labsl_flags_private_handle_accessor -labsl_random_distributions -labsl_flags_usage -labsl_hashtablez_sampler -labsl_flags -labsl_log_internal_conditions -labsl_stacktrace -labsl_log_initialize -labsl_cordz_handle -labsl_log_globals -labsl_random_internal_randen_hwaes -labsl_log_entry -labsl_random_internal_randen_slow -labsl_log_sink -labsl_graphcycles_internal -labsl_time -labsl_cordz_functions -labsl_bad_optional_access -labsl_exponential_biased -labsl_city -labsl_bad_any_cast_impl -labsl_symbolize -labsl_cordz_info -labsl_random_internal_platform -labsl_throw_delegate -labsl_failure_signal_handler -labsl_random_internal_randen_hwaes_impl
error: @programdir/modules/private/async/runjobs.lua:256: @programdir/actions/build/kinds/binary.lua:74: @programdir/core/sandbox/modules/os.lua:267: /usr/bin/ld: /home/fde9/.xmake/packages/a/abseil/master/4e0143c97b65425b855ad5fd03038b6a/lib/libabsl_strings.a(numbers.cc.o): in function `absl::SimpleAtob(std::basic_string_view<char, std::char_traits<char> >, bool*)':
numbers.cc:(.text+0x979): undefined reference to `absl::raw_log_internal::RawLog(absl::LogSeverity, char const*, int, char const*, ...)'
collect2: error: ld returned 1 exit status

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:897]:
    [@programdir/core/sandbox/modules/os.lua:267]: in function 'runv'
    [@programdir/modules/core/tools/gcc.lua:376]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:280]:
    [@programdir/actions/build/kinds/binary.lua:74]: in function 'callback'
    [@programdir/modules/core/project/depend.lua:193]: in function 'on_changed'
    [@programdir/actions/build/kinds/binary.lua:55]: in function '_do_link_target'
    [@programdir/actions/build/kinds/binary.lua:102]:
    [@programdir/actions/build/kinds/binary.lua:129]: in function '_link_target'
    [@programdir/actions/build/kinds/binary.lua:157]: in function 'jobfunc'
    [@programdir/modules/private/async/runjobs.lua:232]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:280]: in function 'trycall'
    [@programdir/core/sandbox/modules/try.lua:117]: in function 'try'
    [@programdir/modules/private/async/runjobs.lua:218]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:388]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:897: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir/modules/private/async/runjobs.lua:256: in field 'catch'
        @programdir/core/sandbox/modules/try.lua:123: in global 'try'
        @programdir/modules/private/async/runjobs.lua:218: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>
@qycyfjy qycyfjy added the bug label Oct 14, 2022
@waruqi
Copy link
Member

waruqi commented Oct 14, 2022

贴下你这 main 里面的测试代码

@qycyfjy
Copy link
Contributor Author

qycyfjy commented Oct 14, 2022

贴下你这 main 里面的测试代码

简单的一次函数调用

#include <iostream>
#include "absl/strings/numbers.h"

using namespace std;

int main(int argc, char** argv)
{
    int result = 0;
    auto a = absl::SimpleAtoi("123", &result);
    cout << result << endl;
    return 0;
}

@waruqi
Copy link
Member

waruqi commented Oct 15, 2022

再试下

xrepo update-repo
xrepo remove --all -y abseil
xmake f -c
xmake

@qycyfjy
Copy link
Contributor Author

qycyfjy commented Oct 15, 2022

ok了,十分感谢

@qycyfjy qycyfjy closed this as completed Oct 15, 2022
@qycyfjy
Copy link
Contributor Author

qycyfjy commented Oct 16, 2022

#include "absl/container/flat_hash_map.h"
#include <iostream>

int main(int argc, char **argv) {
  absl::flat_hash_map<int, int> map;
  if (map.contains(1)) {
    return 1;
  }
  std::cout << "not found" << std::endl;
  return 0;
}

也不能正常编译的,原因

图片

 undefined reference to `absl::lts_20220623::hash_internal::CityHash32(char const*, unsigned long)'

看了下abseil仓库absl/container下的的CMakeLists.txt,flat_hash_map依赖absl_hash,absl_hash依赖absl_city
我将absl_hash调整到absl_city之前,可以编译通过

图片

我对cmake不熟悉,只大致看了下它这些子组件之间声明的依赖(例如container),感觉很复杂,不太好手动清理出来一个链接顺序。

在原生使用cmake的情况下,写下absl::***它可能会自动顺着声明处理?xmake下用什么解决呢?配置下cmake提前打包出来一个libabsl.a之类的完整大包?

@qycyfjy qycyfjy reopened this Oct 16, 2022
@waruqi
Copy link
Member

waruqi commented Oct 16, 2022

我现在只是稍微调整了下顺序,你可以提个 pr 过来 继续改进包里面 links 的顺序。。

在原生使用cmake的情况下,写下absl::***它可能会自动顺着声明处理?xmake下用什么解决呢?配置下cmake提前

没用,对外导出 只能自己配置,xmake 不解析 cmakelists

@waruqi
Copy link
Member

waruqi commented Oct 16, 2022

merge了,再试试

@qycyfjy
Copy link
Contributor Author

qycyfjy commented Oct 16, 2022

可以了

图片

@qycyfjy qycyfjy closed this as completed Oct 16, 2022
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