SWIGを使用して、次のコマンドでGoにいくつかのC++関数を公開しています。
gcc -std=c++0x -Wall -Wextra -pedantic -fPIC -shared -L./lib -lsomething -o example.so
swig -go -intgosize 32 example.i
go tool 6g example.go
go tool 6c -I /usr/lib/go/pkg/linux_amd64 -D_64BIT example_gc.c
go tool pack grc example.a example.6 example_gc.6
rm -f example_wrap.c
go install // this installs the generated .a; not the .so
私のプロジェクトでは、/ src:/ pkg:/ binファイル構造を使用しており、$GOHOMEがそれを指しています。import "example"
別のGoパッケージで使用すると、次のようになります。
error while loading shared libraries: example.so: cannot open shared object file: No such file or directory
共有ライブラリをどこに配置すれば、それが見つかるようになりますか?システムディレクトリをいじることなく。