I want to run the NER examples of a promising entity extraction library here:
Config step works fine but complains about old cmake, then when compiling I get lots of “undefined reference” errors related to socket calls, and a warning about the linker.
I have not much experience porting stuff to Haiku, is it some missing adaptation, is the cmake installation just too old, or is Haiku really missing some functionality to make this library work?
~/Develop/SEN/NER/GLiNER.cpp/examples> cmake --build build --target inference -j
[ 1%] Built target tokenizers_c
[ 7%] Built target tokenizer_cpp_objs
[ 83%] Built target sentencepiece-static
[ 85%] Built target tokenizers_cpp
[ 96%] Built target gliner
[ 98%] Linking CXX executable inference
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: warning: /boot/system/develop/lib/crtn.o: missing .note.GNU-stack section implies executable stack
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: GLiNER.cpp/deps/tokenizers-cpp/release/libtokenizers_c.a(std-2d470cba23f40e31.std.9b903c7c25c6c255-cgu.10.rcgu.o): in function `std::net::udp::UdpSocket::set_read_timeout':
std.9b903c7c25c6c255-cgu.10:(.text._ZN3std3net3udp9UdpSocket16set_read_timeout17h4097d7ce5ec5c4dbE+0x80): undefined reference to `setsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: GLiNER.cpp/deps/tokenizers-cpp/release/libtokenizers_c.a(std-2d470cba23f40e31.std.9b903c7c25c6c255-cgu.10.rcgu.o): in function `std::net::udp::UdpSocket::set_write_timeout':
std.9b903c7c25c6c255-cgu.10:(.text._ZN3std3net3udp9UdpSocket17set_write_timeout17hcefff2e9e0dabd98E+0x80): undefined reference to `setsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: GLiNER.cpp/deps/tokenizers-cpp/release/libtokenizers_c.a(std-2d470cba23f40e31.std.9b903c7c25c6c255-cgu.10.rcgu.o): in function `std::net::udp::UdpSocket::set_broadcast':
std.9b903c7c25c6c255-cgu.10:(.text._ZN3std3net3udp9UdpSocket13set_broadcast17h9012b667688838d1E+0x23): undefined reference to `setsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: GLiNER.cpp/deps/tokenizers-cpp/release/libtokenizers_c.a(std-2d470cba23f40e31.std.9b903c7c25c6c255-cgu.10.rcgu.o): in function `std::net::udp::UdpSocket::broadcast':
std.9b903c7c25c6c255-cgu.10:(.text._ZN3std3net3udp9UdpSocket9broadcast17h31d81b857142a5abE+0x2d): undefined reference to `getsockopt'
...
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: GLiNER.cpp/deps/tokenizers-cpp/release/libtokenizers_c.a(std-2d470cba23f40e31.std.9b903c7c25c6c255-cgu.05.rcgu.o): in function `std::sys_common::net::TcpListener::take_error':
std.9b903c7c25c6c255-cgu.05:(.text._ZN3std10sys_common3net11TcpListener10take_error17hd0d1d678c420b51dE+0x2c): undefined reference to `getsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: GLiNER.cpp/deps/tokenizers-cpp/release/libtokenizers_c.a(std-2d470cba23f40e31.std.9b903c7c25c6c255-cgu.05.rcgu.o): in function `std::sys_common::net::UdpSocket::bind':
std.9b903c7c25c6c255-cgu.05:(.text._ZN3std10sys_common3net9UdpSocket4bind17h04cada127358d3dcE+0xd1): undefined reference to `bind'
...
collect2: error: ld returned 1 exit status
CMakeFiles/inference.dir/build.make:101: recipe for target 'inference' failed
make[3]: *** [inference] Error 1
CMakeFiles/Makefile2:236: recipe for target 'CMakeFiles/inference.dir/all' failed
make[2]: *** [CMakeFiles/inference.dir/all] Error 2
CMakeFiles/Makefile2:243: recipe for target 'CMakeFiles/inference.dir/rule' failed
make[1]: *** [CMakeFiles/inference.dir/rule] Error 2
Makefile:189: recipe for target 'inference' failed
make: *** [inference] Error 2
turns out this beast is not easy to tame, ran into a persistent snag with linking and the build does not respect the -fPIC flag defined in the common cmake config:
[ 16%] Linking CXX executable flatc
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: CMakeFiles/flatc.dir/src/idl_parser.cpp.o: relocation R_X86_64_PC32 against symbol `_ZTVN11flatbuffers9AllocatorE' can not be used when making a shared object; recompile with -fPIC
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
_deps/flatbuffers-build/CMakeFiles/flatc.dir/build.make:656: recipe for target '_deps/flatbuffers-build/flatc' failed
make[2]: *** [_deps/flatbuffers-build/flatc] Error 1
CMakeFiles/Makefile2:7110: recipe for target '_deps/flatbuffers-build/CMakeFiles/flatc.dir/all' failed
make[1]: *** [_deps/flatbuffers-build/CMakeFiles/flatc.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2
Since it works for other sub modules, I opened an issue to see if it’s maybe a bug in the build after all:
For libnetwork there are multiple ways on llinking it (depending on the linking error), the one mentioned by @Lrrr , the one you mention and one using target_link_libraries as used in:
For fPIC search if POSITION_INDEPENDENT_CODE is used in one of the cmake files, you should be able to set OFF in there. Like in:
Strike that last one, I see you tried that (it’s mentioned in the upstream issue).
OK, seems that you need to hunt down POSITION_INDEPENDENT_CODE and turn it off (there are multiple files (not that much) where this is set to “ON”.
Still running into an error though:
[ 16%] Building CXX object _deps/flatbuffers-build/CMakeFiles/flatc.dir/grpc/src/compiler/swift_generator.cc.o
[ 16%] Building CXX object _deps/flatbuffers-build/CMakeFiles/flatc.dir/grpc/src/compiler/ts_generator.cc.o
[ 17%] Linking CXX executable flatc
[ 17%] Built target flatc
[ 17%] Building CXX object _deps/flatbuffers-build/CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o
[ 17%] Building CXX object _deps/flatbuffers-build/CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o
[ 17%] Building CXX object _deps/flatbuffers-build/CMakeFiles/flatbuffers.dir/src/reflection.cpp.o
[ 17%] Building CXX object _deps/flatbuffers-build/CMakeFiles/flatbuffers.dir/src/util.cpp.o
[ 17%] Linking CXX static library libflatbuffers.a
[ 17%] Built target flatbuffers
[ 17%] Building CXX object CMakeFiles/onnxruntime_flatbuffers.dir/Share/wip/onnxruntime/onnxruntime/core/flatbuffers/flatbuffers_utils.cc.o
[ 17%] Linking CXX static library libonnxruntime_flatbuffers.a
[ 17%] Built target onnxruntime_flatbuffers
[ 17%] Building CXX object _deps/abseil_cpp-build/absl/base/CMakeFiles/absl_log_severity.dir/log_severity.cc.o
[ 17%] Linking CXX static library libabsl_log_severity.a
[ 17%] Built target absl_log_severity
[ 17%] Building CXX object _deps/abseil_cpp-build/absl/base/CMakeFiles/absl_raw_logging_internal.dir/internal/raw_logging.cc.o
[ 17%] Linking CXX static library libabsl_raw_logging_internal.a
[ 17%] Built target absl_raw_logging_internal
[ 17%] Building CXX object _deps/abseil_cpp-build/absl/base/CMakeFiles/absl_spinlock_wait.dir/internal/spinlock_wait.cc.o
[ 17%] Linking CXX static library libabsl_spinlock_wait.a
[ 17%] Built target absl_spinlock_wait
[ 17%] Building CXX object _deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/internal/cycleclock.cc.o
[ 17%] Building CXX object _deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/internal/spinlock.cc.o
[ 17%] Building CXX object _deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/internal/sysinfo.cc.o
/Share/wip/onnxruntime/build/Linux/Debug/_deps/abseil_cpp-src/absl/base/internal/sysinfo.cc: In function 'pid_t absl::lts_20240722::base_internal::GetTID()':
/Share/wip/onnxruntime/build/Linux/Debug/_deps/abseil_cpp-src/absl/base/internal/sysinfo.cc:470:10: error: invalid 'static_cast' from type 'pthread_t' {aka '_pthread_thread*'} to type 'pid_t' {aka 'int'}
470 | return static_cast<pid_t>(pthread_self());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Share/wip/onnxruntime/build/Linux/Debug/_deps/abseil_cpp-src/absl/base/internal/sysinfo.h:28,
from /Share/wip/onnxruntime/build/Linux/Debug/_deps/abseil_cpp-src/absl/base/internal/sysinfo.cc:15:
/boot/system/develop/headers/posix/sys/types.h:61:17: note: class type '_pthread_thread' is incomplete
61 | typedef struct _pthread_thread *pthread_t;
| ^~~~~~~~~~~~~~~
_deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/build.make:106: recipe for target '_deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/internal/sysinfo.cc.o' failed
make[2]: *** [_deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/internal/sysinfo.cc.o] Error 1
CMakeFiles/Makefile2:3423: recipe for target '_deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/all' failed
make[1]: *** [_deps/abseil_cpp-build/absl/base/CMakeFiles/absl_base.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
ok so you have to turn it OFF instead of ON, strange but better for performance from the comments.
I found an issue for the error you get but couldn’t yet find a way around it - even using the other method from the native client branch doesn’t work since the sizes are different (4 vs 8 bytes), so the assertion fails (and ignoing it didn’t help, either;-)
It’s also set in the global cmake options for POSIX systems, but the compiler error was very misleading since it actually told me to turn this option on and compile with -fPIC …
That’s awesome, thanks @Begasus !
So what’s ProjectX?
There’s a clash with the versions, so I cannot install the debuginfo package, I think it’s just the version 1.17.0 (onnx) vs. 1.17.0-1 (debuginfo):
problem 1: nothing provides projectx==1.17.0 needed by onnx_debuginfo-1.17.0-1
However, with the new native version I get linker errors again, it can’t find a symbol that should be there (GetOrtApiBase):
~/Develop/SEN/NER/sen-extractor> make clean && make
rm -rf "objects.x86_64-cc13-release"
mkdir -p objects.x86_64-cc13-release; \
mkdepend -I./ -Iinclude -p .cpp:objects.x86_64-cc13-release/%n.o -m -f "objects.x86_64-cc13-release/App.d" App.cpp
g++ -c App.cpp -iquote./ -iquote./ -iquoteinclude -isystemsys -O3 -fPIC -std=c++17 -o "objects.x86_64-cc13-release/App.o"
cc -o "sen-extractor" objects.x86_64-cc13-release/App.o -Xlinker -soname=_APP_ -L./ -Llib -lbe -lstdc++ -lsupc++ -lnetwork -lbsd -lgliner -lonnx -lonnx_proto -ltokenizers_cpp -ltokenizers_c
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: warning: /boot/system/develop/lib/crtn.o: missing .note.GNU-stack section implies executable stack
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: objects.x86_64-cc13-release/App.o: in function `_GLOBAL__sub_I_App.cpp':
App.cpp:(.text.startup+0x525): undefined reference to `OrtGetApiBase'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: lib/libgliner.a(model.cpp.o): in function `_GLOBAL__sub_I_model.cpp':
model.cpp:(.text.startup+0x15): undefined reference to `OrtGetApiBase'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: lib/libgliner.a(decoder.cpp.o): in function `_GLOBAL__sub_I_decoder.cpp':
decoder.cpp:(.text.startup+0x15): undefined reference to `OrtGetApiBase'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: lib/libgliner.a(processor.cpp.o): in function `_GLOBAL__sub_I_processor.cpp':
processor.cpp:(.text.startup+0x15): undefined reference to `OrtGetApiBase'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: lib/libgliner.a(tokenizer_utils.cpp.o): in function `_GLOBAL__sub_I_tokenizer_utils.cpp':
tokenizer_utils.cpp:(.text.startup+0x15): undefined reference to `OrtGetApiBase'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: lib/libgliner.a(gliner_structs.cpp.o):gliner_structs.cpp:(.text.startup+0x15): more undefined references to `OrtGetApiBase' follow
collect2: error: ld returned 1 exit status
/boot/system/develop/etc/makefile-engine:240: recipe for target 'sen-extractor' failed
make: *** [sen-extractor] Error 1
Thanks, just downloaded the latest ones (if you could make a real Haiku pkg repo that would be awesome:).
Sadly, getting the same result, symbol is not found, also not with objdump:(
If you don’t want to wait for my test runs, you can check yourself by trying to compile any of the examples in the GLiNER package…