jermp / fulgor

Fulgor is a fast and space-efficient colored de Bruijn graph index.
MIT License
43 stars 9 forks source link

Missing -lrt linker flag on Ubuntu #21

Closed yhhshb closed 1 year ago

yhhshb commented 1 year ago

Hi @jermp ,

When I compile Fulgor on my machine (Kubuntu 22.04) the compilation fails with some errors that boil down to: ggcat_api.18b922c2ecd02292-cgu.03:(.text._ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hf5334377f827e0d6E+0x4d4): undefined reference toclock_gettime'`

I think this is due to the linker flag -lrt missing when building on linux. Note that on macOS adding -lrt throws errors since macOS does not require the library to be explicitly linked.

Best regards, Yoshihiro Shibuya

jermp commented 1 year ago

Hi @yhhshb, in the readme, we have this:

  # add the rt flag if requested by the user
  if (LINK_LIBRT)
    if (APPLE)
      MESSAGE(STATUS "linking with rt shoul not be necessary on OSX; not adding rt")
    else()
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt")
    endif()
  endif()

So I think you should compile with -DLINK_LIBRT=On. Can you please try?

Thanks!

yhhshb commented 1 year ago

Hi @jermp,

Yes, now that you pointed it out I see it in the CMakeLists.txt (not the Readme). This solves the issue, but may I suggest to put the rt flag as an optional target_link_library just after the current block of linking options?

if (LINUX)
  target_link_libraries(fulgor rt)
endif()

This has the advantage of not requiring the user to remember adding the -DLINK_LIBRT=On option.

jermp commented 1 year ago

Done, thank you!