Build caffe with Python ( cannot find -lboost_python3 ) - python

I'm trying to build caffe with python but it keep saying this
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
/usr/bin/ld: cannot find -lboost_python3
collect2: error: ld returned 1 exit status
make: *** [python/caffe/_caffe.so] Error 1
This is what I get when I try to locate boost_python
$ sudo locate boost_python
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.55.0
/usr/lib/x86_64-linux-gnu/libboost_python-py33.a
/usr/lib/x86_64-linux-gnu/libboost_python-py33.so
/usr/lib/x86_64-linux-gnu/libboost_python-py33.so.1.55.0
/usr/lib/x86_64-linux-gnu/libboost_python-py34.a
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0
/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python.so
I've add this path also
## .bashrc
export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu":$LD_LIBRARY_PATH
Any idea why is that happing?

I've found the problem. it turned out that it tries to look for something with that name of libboost_python3.so after changing the name in Makefile.config from boost_python3 to boost_python-py34, it worked just fine!

I know this thread is quite old, but :
dnf install boost-python3-devel
may help !

I wanted to build Caffe and faced the same issue. Unfortunately, none of the answers work in my case. I checked the location of lboost_python by the following command:
find /usr/lib -name libboost_python-py
I found the lboost_python libraries and here are some of them:
libboost_python37.a
libboost_python37-mt.a
libboost_python37-mt.so
libboost_python37-mt.so.1.68.0
Then in the Makefile.config file I changed the following line:
PYTHON_LIBRARIES := boost_python python3.7m to
PYTHON_LIBRARIES := boost_python37-mt python3.7m

Related

[cgo]Python C API Error: undefined reference to 'Py_True'

Environment:
Ubuntu20.04,Golang 1.9.2,Python 3.7.10
I am trying to use this package: https://github.com/DataDog/go-python3
The problem happened when 'go get github.com/DataDog/go-python3' was executed.
By the way, I have noticed that there is a similar issure:https://github.com/DataDog/go-python3/issues/41. However the answer does not work for me.
I use 'go get -x' to chech what is happening:
mininet#mininet-vm:~/go/src/Dockerfiles$ go get -x github.com/DataDog/go-python3
...
pkg-config --cflags python3
pkg-config --libs python3
CGO_LDFLAGS="-g" "-O2" "-L/opt/py/lib" "-lpython3.7m" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir
...
# github.com/DataDog/go-python3
/usr/bin/ld: $WORK/github.com/DataDog/go-python3/_obj/_cgo_main.o:/tmp/go-build/github.com/DataDog/go-python3/_obj/cgo-generated-wrappers:236: undefined reference to `Py_True'
/usr/bin/ld: $WORK/github.com/DataDog/go-python3/_obj/_cgo_main.o:/tmp/go-build/github.com/DataDog/go-python3/_obj/cgo-generated-wrappers:233: undefined reference to `Py_None'
/usr/bin/ld: $WORK/github.com/DataDog/go-python3/_obj/_cgo_main.o:/tmp/go-build/github.com/DataDog/go-python3/_obj/cgo-generated-wrappers:230: undefined reference to `Py_False'
collect2: error: ld returned 1 exit status
see CGOFLAGS, I have add '-L/opt/py/lib -lpython3.7m' correctly to the end by using pkg-config and setting 'PKG_CONFIG_PATH' and 'LD_LIBRARY_PATH' varibles.
I don't know what happened, maybe go 1.9 is too old? But It seems like a link problem.
I use VM and docker to retry. And the problem is the same.
Thanks for all your possible help.

"fatal error: Eigen/Core: No such file or directory" while installing OpenCV on Ubuntu

I'm installing opencv for Python in Ubuntu 18.04 LTS from the official OpenCV release here https://docs.opencv.org/4.1.0/d2/de6/tutorial_py_setup_in_ubuntu.html
after creating the build directory and entering cmake ../ the moment I enter the command to make it's giving me the following error -
Previously I've used OpenCV on Windows. I'm new in Ubuntu. Please help.
In file included from /home/avi/opencv/modules/core/test/test_precomp.hpp:12:0,
from /home/avi/opencv/build/modules/core/opencv_test_core_pch_dephelp.cxx:1:
/home/avi/opencv/modules/core/include/opencv2/core/private.hpp:66:12: fatal error: Eigen/Core: No such file or directory
# include <Eigen/Core>
^~~~~~~~~~~~
compilation terminated.
modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/build.make:62: recipe for target 'modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.o] Error 1
CMakeFiles/Makefile2:1287: recipe for target 'modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Go to /home/avi/opencv/modules/core/include/opencv2/core/private.hpp file.
Edit the line: # include <Eigen/Core> to # include <eigen3/Eigen/Core>
Read more about this error from here.
Seems like OpenCV did not find Eigen where it was expecting.
Supposing you installed Eigen:
sudo apt-get install libeigen3-dev
The most correct way would be for you to specify to OpenCV where you installed Eigen by setting the variable EIGEN_INCLUDE_PATH, usually to \usr\include, but check your system.
Another option, instead of editing the OpenCV code, is to create some links between where you installed Eigen, and where OpenCV expects it to be:
cd /usr/include
sudo ln -sf eigen3/Eigen Eigen
sudo ln -sf eigen3/unsupported unsupported
I didn't find the solution for me in this post so I may as well share it if somebody comes by.
Problem : The include was looking for an include called Eigen while I installed Eigen3.
Solution : Create a soft link to create a directory called Eigen that redirect to Eigen3.
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen
https://www.programmersought.com/article/44372970691/

Installing megam for NLTK on Windows

I need to install megam for nltk classification routines in Python.
I followed the instruction by Milk Magic from this post:
0. Downloaded megam source from http://www.umiacs.umd.edu/~hal/megam/index.html
1. Installed cygwin with gcc, make and ocaml packages
2. changed the makefile
3. when trying to compile megam with a makefile I receive an error with the following content
make
ocamldep *.mli *.ml > .depend
ocamlc -g -custom -o megam str.cma -cclib -lcamlstr bigarray.cma -cclib -lbigarray unix.cma -cclib -lunix -I /lib/ocaml/caml fastdot_c.c fastdot.cmo intHashtbl.cmo arry.cmo util.cmo data.cmo bitvec.cmo cg.cmo wsemlm.cmo bfgs.cmo pa.cmo perceptron.cmo radapt.cmo kernelmap.cmo abffs.cmo main.cmo
sh: flexlink: command not found
File "fastdot_c.c", line 1:
Error: Error while building custom runtime system
make: *** [Makefile:101: megam] Error 2
Do you know what the problem might be?
Maybe somebody has solved the same problem recently and could help.
As the error is
sh: flexlink: command not found
you need to find the package that contains it
$ cygcheck -p flexlink
Found 5 matches for flexlink
flexdll-0.34-1 - flexdll: Creates DLLs with runtime symbol resolution (installed binaries and support files)
flexdll-0.35-1 - flexdll: Creates DLLs with runtime symbol resolution (installed binaries and support files)
flexdll-0.35-2 - flexdll: Creates DLLs with runtime symbol resolution
...
So you need to install the flexdll package.
$ cygcheck -l flexdll |grep bin
/usr/bin/flexlink

Kivy compiling errors on macos

trying to compile for iOS my very first python kivy project on macos.
http://kivy.org/docs/guide/packaging-ios.html
$ git clone git://github.com/kivy/kivy-ios
$ cd kivy-ios
$ tools/build-all.sh
If I try to build, terminal works a while and at the end I get this error:
....
['/Users/xxx/kivy-ios/tools/liblink', '-arch', 'armv7', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk', '-miphoneos-version-min=7.1', '-arch', 'armv7', '-pipe', '-no-cpp-precomp', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk', '-miphoneos-version-min=7.1', '-O3', '-Qunused-arguments', 'build/temp.macosx-10.9-armv7-2.7/ios.o', 'build/temp.macosx-10.9-armv7-2.7/ios_mail.o', 'build/temp.macosx-10.9-armv7-2.7/ios_browser.o', '-o', 'build/lib.macosx-10.9-armv7-2.7/ios.so']
Unknown option: -Qunused-arguments
error: command '/Users/fribu/kivy-ios/tools/liblink' failed with exit status 1
Any Idea?
A quick search indicate it's a flag that clang doesn't know, i don't know kivy-ios much, but this patch https://github.com/JanX2/Etoile/commit/e7b2a3484726d3c3e8b0c0a1cb879021e851a911 should give you a lead at fixing this.

"cannot find -lpq" when trying to install psycopg2

Intro: I'm trying to migrate our Trac SQLite to a PostgreSQL backend, to do that I need psycopg2. After clicking past the embarrassing rant on www.initd.org I downloaded the latest version and tried running setup.py install. This didn't work, telling me I needed mingw. So I downloaded and installed mingw.
Problem: I now get the following error when running setup.py build_ext --compiler=mingw32 install:
running build_ext
building 'psycopg2._psycopg' extension
writing build\temp.win32-2.4\Release\psycopg\_psycopg.def
C:\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.4\Release\psycopg
\psycopgmodule.o build\temp.win32-2.4\Release\psycopg\pqpath.o build\temp.win32-
2.4\Release\psycopg\typecast.o build\temp.win32-2.4\Release\psycopg\microprotoco
ls.o build\temp.win32-2.4\Release\psycopg\microprotocols_proto.o build\temp.win3
2-2.4\Release\psycopg\connection_type.o build\temp.win32-2.4\Release\psycopg\con
nection_int.o build\temp.win32-2.4\Release\psycopg\cursor_type.o build\temp.win3
2-2.4\Release\psycopg\cursor_int.o build\temp.win32-2.4\Release\psycopg\lobject_
type.o build\temp.win32-2.4\Release\psycopg\lobject_int.o build\temp.win32-2.4\R
elease\psycopg\adapter_qstring.o build\temp.win32-2.4\Release\psycopg\adapter_pb
oolean.o build\temp.win32-2.4\Release\psycopg\adapter_binary.o build\temp.win32-
2.4\Release\psycopg\adapter_asis.o build\temp.win32-2.4\Release\psycopg\adapter_
list.o build\temp.win32-2.4\Release\psycopg\adapter_datetime.o build\temp.win32-
2.4\Release\psycopg\_psycopg.def -LC:\Python24\libs -LC:\Python24\PCBuild -Lc:/P
ROGRA~1/POSTGR~1/8.3/lib -lpython24 -lmsvcr71 -lpq -lmsvcr71 -lws2_32 -ladvapi32
-o build\lib.win32-2.4\psycopg2\_psycopg.pyd
C:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot fin
d -lpq
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
What I've tried - I noticed the forward slashes in the -L option, so I manually entered my PostgreSQL lib directory in the library_dirs option in the setup.cfg, to no avail (the call then had a -L option with backslashes, but the error message stayed the same).
Have you tried the binary build of psycopg2 for windows? If that works with your python then it mitigates the need to build by hand.
I've seen random people ask this question on various lists and it seems one recommendation is to build postgresql by hand to work around this problem.
Compiling extensions on windows can be tricky. There are precompiled libraries available however: http://www.stickpeople.com/projects/python/win-psycopg/

Categories