adiar
adiar copied to clipboard
Build as a Shared Library
Describe the bug It is not possible to build Adiar as a shared library.
To Reproduce
Try to build the make main
target changed such that CMake also is parsed the value -D ADIAR_SHARED = ON
. Building the Adiar library itself and also main.cpp works fine, but linking main.cpp to Adiar does not work at all.
[100%] Linking CXX executable adiar_main
/usr/bin/ld: CMakeFiles/adiar_main.dir/main.cpp.o: in function `main':
/home/soelvsten/git/adiar/src/main.cpp:20: undefined reference to `adiar::adiar_init(unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /home/soelvsten/git/adiar/src/main.cpp:30: undefined reference to `adiar::adiar_printstat(std::ostream&)'
/usr/bin/ld: /home/soelvsten/git/adiar/src/main.cpp:32: undefined reference to `adiar::adiar_deinit()'
collect2: error: ld returned 1 exit status
make[4]: *** [src/CMakeFiles/adiar_main.dir/build.make:102: src/adiar_main] Error 1
make[4]: Leaving directory '/home/soelvsten/git/adiar/build'
make[3]: *** [CMakeFiles/Makefile2:257: src/CMakeFiles/adiar_main.dir/all] Error 2
make[3]: Leaving directory '/home/soelvsten/git/adiar/build'
make[2]: *** [CMakeFiles/Makefile2:264: src/CMakeFiles/adiar_main.dir/rule] Error 2
make[2]: Leaving directory '/home/soelvsten/git/adiar/build'
make[1]: *** [Makefile:215: adiar_main] Error 2
make[1]: Leaving directory '/home/soelvsten/git/adiar/build'
make: *** [makefile:68: main] Error 2
Additional context If we can get Adiar to run as a shared library (with TPIE only inside of it), then the LGPL v3 license of TPIE makes it possible to use this in a closed-source project.
If the user at this point sets ADIAR_SHARED to ON then CMake will crash - there is no reason for it to cryptically fail and have tons of settings that are only related to building it as a shared library.