2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macで.soファイルを試してみる

2
Last updated at Posted at 2019-01-01

Macで.soファイルを試してみた。
ほぼ手順通りだが、Linuxでなく、Macが故にうまく行かない部分があったのでメモ。

その1

  1. sonameの代わりにinstall_name
  • これはうまく行かない
    • gcc -shared -Wl,-soname,libhello.so libhello.lo -o libhello.so
  • 代わりにこれを実行
    • gcc -shared -Wl,-install_name,libhello.so libhello.lo -o libhello.so
  1. ldconfigは不要

その2

  1. javahはjdk10や11では使えなさそう
  1. .soでなく、.jnilibを作成
    https://stackoverflow.com/questions/761639/why-am-i-getting-this-unsatisfiedlinkerror-with-native-code
  • これだとこの後の手順でエラーが出る
    • gcc -fPIC -shared hello.c -I /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/include -I /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/include/darwin/ -o libhello.so
  • こちらに変更
    • gcc -fPIC -shared hello.c -I /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/include -I /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/include/darwin/ -o libhello.jnilib
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?