metagraph icon indicating copy to clipboard operation
metagraph copied to clipboard

Place all relevant headers in /include during installation

Open adamant-pwn opened this issue 1 year ago • 5 comments

Should partially help with #485.

adamant-pwn avatar Jun 20 '24 16:06 adamant-pwn

@hmusta I tried using Metagraph as an external project, and besides problems with includes (that are at least resolved by this commit), I also get a bunch of linking errors:


[100%] Linking CXX executable MyExecutable
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::sink_it_(spdlog::details::log_msg const&)':
main.cpp:(.text._ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE[_ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE]+0x253): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::flush_()':
main.cpp:(.text._ZN6spdlog6logger6flush_Ev[_ZN6spdlog6logger6flush_Ev]+0x24a): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::make_unsigned<long>::type fmt::v10::detail::to_unsigned<long>(long)':
main.cpp:(.text._ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_]+0x21): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned int>(char*, unsigned int, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x3f): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned long>(char*, unsigned long, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x42): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > > fmt::v10::vformat_to<std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, 0>(std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)':
main.cpp:(.text._ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE[_ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE]+0x3e): undefined reference to `void fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)'
collect2: error: ld returned 1 exit status

These are resolved by adding

find_package(spdlog REQUIRED)
target_link_libraries(MyExecutable PRIVATE spdlog::spdlog)

But I assume it uses system-wide spdlog, rather than the one shipped with Metagraph. What would be the proper way to fix this, so that Metagraph installs all of its dependencies when used via ExternalProject_Add?

adamant-pwn avatar Jun 21 '24 11:06 adamant-pwn

@hmusta I tried using Metagraph as an external project, and besides problems with includes (that are at least resolved by this commit), I also get a bunch of linking errors:

[100%] Linking CXX executable MyExecutable
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::sink_it_(spdlog::details::log_msg const&)':
main.cpp:(.text._ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE[_ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE]+0x253): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::flush_()':
main.cpp:(.text._ZN6spdlog6logger6flush_Ev[_ZN6spdlog6logger6flush_Ev]+0x24a): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::make_unsigned<long>::type fmt::v10::detail::to_unsigned<long>(long)':
main.cpp:(.text._ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_]+0x21): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned int>(char*, unsigned int, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x3f): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned long>(char*, unsigned long, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x42): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > > fmt::v10::vformat_to<std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, 0>(std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)':
main.cpp:(.text._ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE[_ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE]+0x3e): undefined reference to `void fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)'
collect2: error: ld returned 1 exit status

These are resolved by adding

find_package(spdlog REQUIRED)
target_link_libraries(MyExecutable PRIVATE spdlog::spdlog)

But I assume it uses system-wide spdlog, rather than the one shipped with Metagraph. What would be the proper way to fix this, so that Metagraph installs all of its dependencies when used via ExternalProject_Add?

AFAIK you can set the path in find_package: https://stackoverflow.com/questions/49816206/cmake-find-package-specify-path

hmusta avatar Jun 21 '24 11:06 hmusta

This is true, but currently Metagraph doesn't even install it in the install dir:

$ ls install/lib/
cmake  libjsoncpp.a  libmetagraph-core.a  libz.a  pkgconfig

Do we want to also put libspdlog.a there and tell third-party users to manually link with it? I'd prefer this to be handled automatically, but I'm not sure what's the proper way to do this...

adamant-pwn avatar Jun 21 '24 12:06 adamant-pwn

This is true, but currently Metagraph doesn't even install it in the install dir:

$ ls install/lib/
cmake  libjsoncpp.a  libmetagraph-core.a  libz.a  pkgconfig

Do we want to also put libspdlog.a there and tell third-party users to manually link with it? I'd prefer this to be handled automatically, but I'm not sure what's the proper way to do this...

I'd prefer to have it be linked statically in libmetagraph-core.a, though the downside of this is that if another library happens to use it, they'd have to use our version. Though we could have a cmake variable called SPDLOG_LINKED or something to control this.

hmusta avatar Jun 21 '24 12:06 hmusta

Isn't it already linked statically the way it is written now? I'm not sure what needs to be updated to ensure it.

adamant-pwn avatar Jul 01 '24 18:07 adamant-pwn

Will continue in #565

adamant-pwn avatar Nov 14 '25 20:11 adamant-pwn