ViennaRNA Package 1.xをmacOS Sierraでビルドする
用があってViennaRNAの1系を使うことがあって、ビルドしようと思ったら通らなかった。
Undefined symbols for architecture x86_64: "_HairpinE", referenced from: _subopt in libRNA.a(libRNA_a-subopt.o) _repeat in libRNA.a(libRNA_a-subopt.o) "_LoopEnergy", referenced from: _subopt in libRNA.a(libRNA_a-subopt.o) _repeat in libRNA.a(libRNA_a-subopt.o) ld: symbol(s) not found for architecture x86_64
リンカーでエラーが出る。nm
でlibRNA_a-fold.o
を確認すると確かにSymbolがundefinedになっていた。
環境
$ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.0.0 (clang-800.0.42.1) Target: x86_64-apple-darwin16.4.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
方法
lib/fold.c
に以下のようにINLINEマクロが定義されているので、変更する。
変更前
27 #ifdef __GNUC__ 28 #define INLINE inline 29 #else 30 #define INLINE 31 #endif
変更後
27 #ifdef __GNUC__ 28 #define INLINE 29 #else 30 #define INLINE 31 #endif
原因
https://clang.llvm.org/compatibility.html#inline
GNU C89 mode (used by default in older versions of GCC) is the C89 standard plus a lot of extensions. C89 doesn’t have an inline keyword, but GCC recognizes it as an extension and just treats it as a hint to the optimizer.
GCC C89モードのinlineはおかしいらしい。以下の方法でもビルドできる
$ CFLAGS=" -std=gnu89 " ./configure