<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118595>118595</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang++ cannot link g++ compiled library
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
WittonBell
</td>
</tr>
</table>
<pre>
When using `Protobuf` in a project, because `Protobuf` relies on the `absl` library, under MinGW64, the `absl` library is compiled using the `gcc` compiler. If the project is compiled using the `clang` compiler, link failures will occur:
`
mingw64/include/absl/log/internal/log_message.h:135:(.text$_ZN4absl12lts_2024072212log_internal10LogMessagelsEy[_ZN4absl12lts_2024072212log_internal10LogMessagelsEy]+0x19): undefined reference to `_ZN4absl12lts_2024072212log_internal10LogMessagelsIyTnNSt9enable_ifIXntsr4absl16HasAbslStringifyIT_EE5valueEiE4typeELi0EEERS2_RKS5_'
`
I looked at the source code of the Absl library, version 2024072212:
`
LogMessage& operator<<(unsigned long long v) { // NOLINT
return operator<< <unsigned long long>(v); // NOLINT
}
template <typename T,
typename std::enable_if<!absl::HasAbslStringify<T>::value, int>::type>
LogMessage& LogMessage::operator<<(const T& v) {
OstreamView view(*data_);
view.stream() << log_internal::NullGuard<T>().Guard(v);
return *this;
}
extern template LogMessage& LogMessage::operator<<(
const unsigned long long& v);
`
The function signature generated by clang is different from the function signature generated by GCC. I don't know if clang has compilation options that can be fully compatible with GCC?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1v4zYQ_TX0ZbCGRH1YOuhgO3ZqNJstNkZT9GJQ0khiQ5MGSdnxvy9IyUqQTVHsGoYEzcebxzfkkBnDW4lYkGRFkrsZ622ndPHMrVVyhULMSlVfi-cOJfSGyxZIGvyhlVVl35A0AC6BwUmrf7CyhK6hxIr1Bj-GaRQcDSgJtvNOVhrhHIKXmumrS-1ljRq-cnn_nMbO8HkocAOVOp64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