Skip to content

[Bug]: flat_hash_map build with linker error #1876

Open
@kamchan0

Description

@kamchan0

Describe the issue

Try to use flat_hash_map in a very simple example code:

#include "absl/container/flat_hash_map.h"

class foo {
	absl::flat_hash_map<int, int> m;
public:
	foo() {
		m[1] = 2;
		m[2] = 3;
		m[3] = 4;
	}
};

int main() {
	foo f;
	return 0;
}

Build it with all possible .a libraries in install folder, but got error below:

hash.cc:(.text+0x30): undefined reference to `absl::hash_internal::CityHash32(char const*, unsigned long)'
/usr/bin/ld: /home/km/git/absl/lib/libabsl_hash.a(hash.cc.o): in function `absl::hash_internal::MixingHashState::CombineContiguousImpl(unsigned long, unsigned char const*, unsigned long, std::integral_constant<int, 4>)':
hash.cc:(.text._ZN4absl13hash_internal15MixingHashState21CombineContiguousImplEmPKhmSt17integral_constantIiLi4EE[_ZN4absl13hash_internal15MixingHashState21CombineContiguousImplEmPKhmSt17integral_constantIiLi4EE]+0x11b): undefined reference to `absl::hash_internal::CityHash32(char const*, unsigned long)'
/usr/bin/ld: /home/km/git/absl/lib/libabsl_raw_hash_set.a(raw_hash_set.cc.o): in function `absl::container_internal::(anonymous namespace)::ResizeEmptyNonAllocatedTableImpl(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, unsigned long, bool)':
raw_hash_set.cc:(.text+0x1a4a): undefined reference to `absl::container_internal::ForcedTrySample(unsigned long, unsigned long, unsigned long, unsigned short)'
/usr/bin/ld: /home/km/git/absl/lib/libabsl_raw_hash_set.a(raw_hash_set.cc.o): in function `absl::container_internal::(anonymous namespace)::ResizeFullSooTable(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, unsigned long, absl::container_internal::(anonymous namespace)::ResizeFullSooTableSamplingMode)':
raw_hash_set.cc:(.text+0x1e23): undefined reference to `absl::container_internal::ForcedTrySample(unsigned long, unsigned long, unsigned long, unsigned short)'
/usr/bin/ld: /home/km/git/absl/lib/libabsl_raw_hash_set.a(raw_hash_set.cc.o): in function `absl::container_internal::(anonymous namespace)::GrowToNextCapacityAndPrepareInsert(absl::container_internal::CommonFields&, absl::container_internal::PolicyFunctions const&, unsigned long)':
raw_hash_set.cc:(.text+0x27b0): undefined reference to `absl::container_internal::ForcedTrySample(unsigned long, unsigned long, unsigned long, unsigned short)'
collect2: error: ld returned 1 exit status

I thought this issue has reported previously and been fixed. But I still encounter this problem.

Steps to reproduce the problem

g++ absl_p.cpp -I/home/km/git/absl/include -L/home/km/git/absl/lib -labsl_base -labsl_city -labsl_civil_time -labsl_cord -labsl_cord_internal -labsl_cordz_functions -labsl_cordz_handle -labsl_cordz_info -labsl_cordz_sample_token -labsl_crc32c -labsl_crc_cord_state -labsl_crc_cpu_detect -labsl_crc_internal -labsl_debugging_internal -labsl_decode_rust_punycode -labsl_demangle_internal -labsl_demangle_rust -labsl_die_if_null -labsl_examine_stack -labsl_exponential_biased -labsl_failure_signal_handler -labsl_flags_commandlineflag -labsl_flags_commandlineflag_internal -labsl_flags_config -labsl_flags_internal -labsl_flags_marshalling -labsl_flags_parse -labsl_flags_private_handle_accessor -labsl_flags_program_name -labsl_flags_reflection -labsl_flags_usage -labsl_flags_usage_internal -labsl_graphcycles_internal -labsl_hash -labsl_hashtablez_sampler -labsl_int128 -labsl_kernel_timeout_internal -labsl_leak_check -labsl_log_flags -labsl_log_globals -labsl_log_initialize -labsl_log_internal_check_op -labsl_log_internal_conditions -labsl_log_internal_fnmatch -labsl_log_internal_format -labsl_log_internal_globals -labsl_log_internal_log_sink_set -labsl_log_internal_message -labsl_log_internal_nullguard -labsl_log_internal_proto -labsl_log_internal_structured_proto -labsl_log_severity -labsl_log_sink -labsl_low_level_hash -labsl_malloc_internal -labsl_periodic_sampler -labsl_poison -labsl_random_distributions -labsl_random_internal_distribution_test_util -labsl_random_internal_entropy_pool -labsl_random_internal_platform -labsl_random_internal_randen -labsl_random_internal_randen_hwaes -labsl_random_internal_randen_hwaes_impl -labsl_random_internal_randen_slow -labsl_random_internal_seed_material -labsl_random_seed_gen_exception -labsl_random_seed_sequences -labsl_raw_hash_set -labsl_raw_logging_internal -labsl_scoped_set_env -labsl_spinlock_wait -labsl_stacktrace -labsl_status -labsl_statusor -labsl_str_format_internal -labsl_strerror -labsl_string_view -labsl_strings -labsl_strings_internal -labsl_symbolize -labsl_synchronization -labsl_throw_delegate -labsl_time -labsl_time_zone -labsl_tracing_internal -labsl_utf8_for_code_point -labsl_vlog_config_internal

What version of Abseil are you using?

latest git clone

What operating system and version are you using?

ubuntu

What compiler and version are you using?

g++ or clang++ have the same problem

What build system are you using?

g++ or clang++ have the same problem

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions