undefined symbol: _ZN2cv3Mat10deallocateEv - python

I've been trying to extend my python script with a C++ code. I was able to do that with the simple libraries of C++ (print "hello world"). I followed the tutorial available in the link below:
http://www.tutorialspoint.com/python/python_further_extensions.htm
When I tried to add to my C++ code opencv libraries I encountered the following problem:
ImportError: /usr/local/lib/python2.7/dist-packages/kalman.so: undefined symbol: _ZN2cv3Mat10deallocateEv
I searched for many solutions on the internet, and I found one common answer that didn't workout for me:
"I was able to solve this by going to /usr/lib64/pkgconfig and modified opencv.pc to explicitly have all libraries. I also had to move the plugins from /usr/lib/gstreamer-0.10 to /usr/lib64/gstreamer-0.10"
Please note that I am using ubuntu 14.04 LTS 64-bit and I am planning to run my code later on on a raspberry pi model B running Raspbian OS.
Thank you.
NJ

Check your shared library kalman.so with ldd like so:
$ ldd kalman.so
And you will see that you are missing some libraries. That means that you have to provide some correct path to one of the libraries you use in your code at the linkage stage. something like
$ ...the way you do linking ... -L path_to_the_missing_library
For more information, please, consult this link.

I've met the same problem as you do, and at last I figured out that this is because I didn't add the linking library of opencv when compiling. Try to add the "opencv_core" or other related library when you compile the c++ source file.
Wish this to be helpful to you.

Related

Failed to build boost_python example code "fatal error LNK1181: cannot open input file 'boost_python.lib'"

I am fairly new to boost python, and I am attempting to follow this tutorial: https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/tutorial/hello.html . Following the tutorial exactly, I receive this error upon building the project using either b2 or bjam:
" fatal error LNK1181: cannot open input file 'boost_python.lib' "
I believe I have properly configured my user-config.jam, jamfile, and jamroot files.
I also saw this thread here:
LNK1181: cannot open input file 'boost_python.lib' in windows, boost_1_68_0
but no solutions to the issue seemed to have been provided. Instead it is suggested that bjam/b2 are not needed at all, which seems to contradict the tutorial in the boost documentation.
The same user then suggested "linking" with the boost python and python libraries, which I assume means to add their directories to system environment variables. I have already done this, but I believe I could be misunderstanding what he meant.
The thread also links to this page:
https://learn.microsoft.com/en-us/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2017
detailing the creation of c++ extensions for Python, but after reading it I fail to see any mention of boost whatsoever except in passing at the very end of the article.
I have also searched the entire boost directory for a 'boost_python.lib' file and it seems that it does not exist. Any help would be greatly appreciated.
A quick Google search brought me to this answer:
You need to build the shared boost_python library using this command:
bjam toolset=msvc --prefix=..\\%BOOST_PREFIX% --with-python
--python=2.7 release link=shared --build-type=complete
address-model=64 install
You might have to adjust some options, but it should work as it worked for someone else.
-u/GeeDeexd

Python for .NET "unable to find assembly" error

I'm using CPython and I have a C# dll. I'm trying to use Python for .NET to make them talk. I can't use IronPython because I need to integrate this into an existing CPython system.
I'm completely new to Python for .NET, and I actually have very little experience with Python and no experience with C#. So please forgive me if my question seems very basic.
I'm using Python 2.7.3, and I downloaded
pythonnet-2.0-alpha2-clr2.0_131_py27_UCS2 and unzipped it into a folder named pyfornet_test, which also contains the dll I'm trying to use (called DotNet4Class.dll)
Then I run this:
import sys
import os
import clr
sys.path.append(r"C:\pyfornet_test")
clr.AddReference("DotNet4Class.dll")
Which gives me this error:
System.IO.FileNotFoundException: Unable to find assembly 'DotNet4Class.dll'.
at Python.Runtime.CLRModule.AddReference(String name) in C:\Users\Barton\Documents\Visual Studio 2008\Projects\PyShar
p\trunk\pythonnet\src\runtime\moduleobject.cs:line 375
Any advice would be much appreciated. Thank you!
One reason can be Windows was not enabling it to load from "external sources". To fix this:
Right-click on the .dll
"Properties"
Under "General", click "Unblock"
Try this (without extension .dll):
clr.AddReference(r"C:\pyfornet_test\DotNet4Class")
Is DotNet4Class.dll built against .NET 4? I assume so based on the naming of the dll.
Note the issue here: http://sourceforge.net/tracker/?func=detail&aid=3293169&group_id=162464&atid=823891
clr.AddReference fails when assembly is built with .NET 4.0 - ID: 3293169
I'd read the solution, but essentially, you need to rebuild and recompile the python for .NET project under .NET 4.
I'll also mention that projects like this, that aren't actively developed and used by lots of people, generally have subtle idiosyncrasies that make knowledge of the platform essential to work around problems such as this. It sounds like you're trying to hack this solution in without understanding much about python or .NET which is always going to be fraught with problems.
Did you try clr.FindAssembly?
import clr
import sys
assemblydir = r"C:\pyfornet_test"
assemblypath = r"C:\pyfornet_test\DotNet4Class.dll"
sys.path.append(assemblydir)
clr.FindAssembly(assemblypath)
I don't know why it works, but this code works on my computer (Python 2.7, .NET4)
I have code like this (I copied MyRightClickMenuService.dll to the same directory as my script.py). It is built against .Net 4.0.
# script.py
import clr
import os
import sys
sys.path.append(os.path.dirname(__file__))
clr.AddReference('MyRightClickMenuService')
clr.AddReference('System')
clr.AddReference('System.Security')
from MyRightClickMenuService import (
AclSecuredNamedPipeBinding,
MyMenuItem,
MyContextMenuService,
etc
)
Checklist
The folder(s) containing the DLL(s) is/are added to sys.path before loading. You may append, or sys.path.insert(0, dll_folder) to put it first on the list.
You call clr.AddReference('my_dll') without the dll extension (for my_dll.dll), after adding the folder to sys.path
The DLL Target Architecture is the same as the CPython version bitness. That is, if Architecture is x64, use 64-bit python, and if Architecture is x86, use 32-bit python. (instructions for this below)
How to check target Architecture for DLL?
I Used ILSpy (free and open source) -> Open DLL -> Check the output. Below example output.
What worked for me was to Unblock the dll file.
if u download the dll file or took it from different computer it might be blocked. So unblocked solved the issue for me.
To unblock right click on the properties if the dll file and check the Unblock box at the bottom

error on importing pyIpopt

I'm trying to install and configure pyIpopt. Ipopt is already installed and the examples run fine.
From the shell, when I do import pyIpopt, I get the error:
ImportError: /***PATH***/libipopt.so.1: undefined symbol: MPI_Init
The FAQ section of the pyIpopt git project has this to offer for these kinds of errors:
Do a Google search to find the library file, and add
-lWhateverLibrary in the makefile of pyipopt.
I've googled and found this: http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Init.html.
I don't know how to get the library or add it to the makefile... Any assistance would be much appreciated!
Just had a similar problem on ubuntu.
Using libmumps-seq worked for me:
installed libmumps-seq-4.9.2 (just with apt-get, along side the ordinary libmumps)
in setup.py changed in the libraries list argument 'coinmumps' to 'dmumps_seq-4.9.2'
rebuilt and installed.
If I understand it correctly, the default mumps is distributed (using MPI lib which can be a world of pain), and all i needed is the sequential one, which mumps-seq provides.

Cannot link boost.python with mingw

I have already build boost.python lib by mingw,Got two lib files:
libboost_python-mgw45-mt-1_46_1.a
libboost_python-mgw45-mt-d-1_46_1.a
But I cant link these libs in my test programs.And the other components like regex works fine.I dont know how to solve this.
my user-config.jam:
using python
: 2.7
: F:\\Programs\\Python\\python # cmd-or-prefix
: F:\\Programs\\Python\\include
: F:\\Programs\\Python\\lib
: <toolset>gcc # condition
;
and the build command:
bjam toolset=gcc --with-python
My Enviroment:
python 2.7
mingw 4.5.1
boost 1.46.1
OS:windows xp
Hope I explained my problem clearly, I'm not english native speaker.
Any advise will be appreciate.
I don't know why (and I never really cared enough to dig for the reason), but Boost.Python refuses to link statically on Windows. This is easily solved, though — just rebuild it as a DLL (bjam toolset=gcc --with-python link=shared).

Problem with building Boost Graph Library Python bindings under Leopard

I've inherited some Python code which is importing boost.graph and I'm having an issue setting up the following under Mac OS X Leopard (I believe this is what I need to install to get it working):
http://osl.iu.edu/~dgregor/bgl-python/
According to the readme I need to build with bjam, but I see the following error:
[matt#imac ~/Downloads/bgl-python-0.9]$ bjam
error: Could not find parent for project at '.'
error: Did not find Jamfile or project-root.jam in any parent directory.
I'm running a full Macports stack of python25, boost, boost-jam, boost-build.
I don't have any experience with building using bjam. Can anyone offer any help?
This error suggests the project is not a standalone, and is meant to be put inside the Boost source tree.

Categories