Reputation: 13
i have the issue.
environment
macbookpro:lib fredlee$ go version go version go1.8.3 darwin/amd64 macbookpro:lib fredlee$ pwd /usr/local/lib macbookpro:lib fredlee$ ls -alh libtensorflow.so -r-xr-xr-x 1 root wheel 102M 1 1 1970 libtensorflow.so macbookpro:lib fredlee$ file libtensorflow.so libtensorflow.so: Mach-O 64-bit dynamically linked shared library x86_64 macbookpro:lib fredlee$
issue
> macbookpro:~ fredlee$ go get
> github.com/tensorflow/tensorflow/tensorflow/go macbookpro:~ fredlee$
> go test github.com/tensorflow/tensorflow/tensorflow/go
> # github.com/tensorflow/tensorflow/tensorflow/go ld: library not found for -ltensorflow clang: error: linker command failed with exit code 1
> (use -v to see invocation)
> FAIL github.com/tensorflow/tensorflow/tensorflow/go [build failed]
anyone can help me make it works?
Upvotes: 0
Views: 419
Reputation: 306
I do not quit understand why you test a third-party package. But from your error, looks like a lib called ld
is not found. If it is needed the the package, then I believe It should be installed in the $GOPATH/bin. So, please try:
export PATH=$PATH:$GOPATH/bin
Upvotes: 0
Reputation: 27070
The error is pretty clear:
ld: library not found for -ltensorflow
When you run go test
you're invoking the go compiler that compiles the required libraries, your test files and then executes them.
When you compile a program that uses a "non-pure" go library, you have to make the compiler (and the linker) aware of the library.
In the compilation phase, the compiler looks for the libraries (also) in the paths listed into the environment variable:
LIBRARY_PATH
on OS X & Linux.
Thus you have to add into this variable the location of the compiled library.
For example I have:
TFGOLIB="${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow"
export LIBRARY_PATH="${TFGOLIB}:${LIBRARY_PATH}"
During the runtime, instead, the os looks for the library in order to perform dynamic linking.
Thus you have to set this other variable (LD_LIBRARY_PATH
on Linux and DYLD_LIBRARY_PATH
on OS X) to the same location.
Moreover I suggest you to also add the CUDA library path to this variable, in order to make it available at runtime.
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/cuda/lib64:/opt/cuda/extras/CUPTI/lib64:/opt/cudnn5.1/cuda/lib64:${TFGOLIB}"
Upvotes: 3