使用外部lib进行Go + Swig构建

Pie*_*ert 2 c++ swig pkg-config go

我正在尝试使用opencv函数构建一个cpp文件.

去1.3说swig构建现在捆绑在go构建工具中但是我没有找到一种方法来告诉构建工具添加包含dirs和libs args和pkg-config.

go test -x cv_test.go                                                  
cd /Users/pierre/Projects/go-swig
clang++ -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -g -O2 -o $WORK/_/Users/pierre/Projects/go-swig/_obj/binding.cpp.o -c ./binding.cpp
# _/Users/pierre/Projects/go-swig
In file included from ./binding.cpp:1:
./binding.h:5:10: fatal error: 'cv.h' file not found
$WORK/command-line-arguments/_test/tiler.test
FAIL    command-line-arguments [build failed]
Run Code Online (Sandbox Code Playgroud)

有人做过成功吗?

One*_*One 5

截至目前,如果你使用pkg-config,Go没有正确地将包含路径传递给swig,我提交了一个补丁,但很可能在1.4出局之前不会包含它.

因此,您要么使用补丁构建Go,要么手动指定#cgo CXXFLAGS / #cgo LDFLAGS类似@JamesHenstridge建议的路径.