smarco / WFA2-lib

WFA-lib: Wavefront alignment algorithm library v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fatal error: 'endian.h' file not found on M1 mac

rlorigro opened this issue · comments

Hi,

I unfortunately need to compile this library on an M1 Mac and I am running into an error:

[1%] Building C object CMakeFiles/wfa2.dir/wavefront/wavefront_extend_kernels.c.o
/Users/rlorigro/code/sv_merge/build/project_wfa-prefix/src/project_wfa/wavefront/wavefront_extend_kernels.c:32:10: fatal error: 'endian.h' file not found
#include <endian.h>
         ^~~~~~~~~~

clang:

Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

on macOS Sonoma 14.2 (23C64)

Based on some quick googling it may be as simple as using <machine/endian.h> in this particular context

Thanks

I tried using #include <endian.h> and #include <machine/endian.h> in my own project and <machine/endian.h> works but the other does not.

After some more searching I learned that using <sys/types.h> is supposed to be more portable than trying to include endian.h directly. I made a fork and tested it on my system and it works.

To be honest, I'm not sure why my build system doesn't activate the conditional clause if defined(__APPLE__) that you already had there. But it may have something to do with how I have compiled/linked in CMake:

ExternalProject_Add(project_wfa
        URL https://github.com/smarco/WFA2-lib/archive/refs/tags/v2.3.4.tar.gz
        TIMEOUT 5
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/external/wfa2 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH=${CMAKE_SOURCE_DIR}/external/wfa2/lib/
        INSTALL_COMMAND make install
)

add_library(wfa2 SHARED IMPORTED)
set_property(TARGET wfa2
        PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/external/wfa2/lib/libwfa2cpp.${LIB_SUFFIX})
#                                            /sv_merge/external/wfa2/lib

add_dependencies(wfa2 project_wfa)
add_dependencies(sv_merge wfa2)

# Specify include dir
include_directories(
        ${CMAKE_SOURCE_DIR}/external/wfa2/include/wfa2lib
)

Let me know your thoughts. I would prefer not to use a fork if possible. Maybe I am missing something simple.

Hi,

Thanks for the report and sorry for the terrible delay in answering. I am not an expert on macOS but I appreciate your research and looks good to me. Would you like to make a PR to development and get the credit for the patch?

Let me know,

sure, PR is up now