I'm trying to use boost.python and build a python extension from c++.
My cpp file use a function named 'BZ2_bzopen' which is in the library 'libbz2' under standard path (/usr/lib/). However, when I try to build the extension using boost build following the instruction, I received an error said:
====== BEGIN OUTPUT ======
Traceback (most recent call last):
File "CrossTrade.py", line 11, in <module>
from custom_c import GoThroughFile
ImportError: /home/jliu/toolpak/custom_c.so: undefined symbol: BZ2_bzopen
EXIT STATUS: 1
====== END OUTPUT ======
This seems to me as an error comes from not linking to the library, which is almost the same as if I compile the cpp file without the '-lbz2' command.
Anyone could offer some help on solving it, please?
Maybe you did not link to libbz2? In that case, follow the instructions in http://www.boost.org/doc/libs/1_46_1/doc/html/bbv2/tutorial.html#bbv2.tutorial.prebuilt to see how to link to libraries.
Related
I have been able to implement an algorithm in C++ (error level analysis algorithm for JPEG images) and I have also been able to compile a Python wrapper for the code using cython but at the time of testing it I am facing issues.
This is the Link to my previously asked question containing the source code and all relevant information regarding the following post.
I have created a wrapper function for my C++ code and built it using cython but at the time time of testing I a getting the following error:
Traceback (most recent call last):
File "Test.py", line 1, in <module>
import ela
ImportError: /home/shreyash/Desktop/New/ela.so: undefined symbol:_ZN2cv14createTrackbarERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_PiiPFviPvES9_
There seems to some problem with the createtrackbar symbol in the shared object file which is somehow undefined.
The problem was with configurations of the setup.py file , i just had to expicitly specify all the libraries being used by my opencv implementation.
After compiling with the help of cython it generated a shared object file
which had all the defined symbols.
I have Arch linux. When I try to open acestreamengine, I got this error:
$ sudo acestreamengine --client-console
2017-07-15 10:36:06,535|MainThread|acestream|error during startup
Traceback (most recent call last):
File "core.c", line 1590, in
File "core.c", line 144, in
File "core.c", line 2, in
ImportError: cannot import name __m2crypto
Currently I have version m2crypto-26-0
Someone can help me? I can not start the engine.
Thanks
Best regards.
If you can't downgrade M2Crypto version you can put it's earlier version to the Acestream lib directory.
For example, you can download M2Crypto from https://archive.archlinux.org/packages/p/python2-m2crypto/python2-m2crypto-0.23.0-2-x86_64.pkg.tar.xz and move M2Crypto* directories from usr/lib/python2.7/site-packages folder to <acestream_home>/lib
Try to use an earlier version of M2Crypto.
Version 0.23 works just fine.
I'm using Slackware 14.2
I had already had sublime and when setting up new plug-ins, I found problem for the setup of SublimeClang. It requires libClang but I searched all my folders using the " locate clang" command and couln't find libclang at last (The doc on the web said it should be located in usr/lib/x86_64-linux-gnu/).
When i open the sublime, the console printed out like this:
Traceback (most recent call last):
File "/home/meng/.config/sublime-text-3/Packages/SublimeClang/internals/clang/cindex.py", line 95, in get_cindex_library
return cdll.LoadLibrary(filename)
File "./ctypes/__init__.py", line 431, in LoadLibrary
File "./ctypes/__init__.py", line 353, in __init__
OSError: libclang.so: cannot open shared object file: No such file or directory
error: It looks like libclang.so couldn't be loaded. You have to compile it yourself, or download from https://github.com/quarnster/SublimeClang/downloads.
Please note that this plugin uses features from clang 3.0 so make sure that is the version you have installed.
Once you have the file, you need to copy libclang.so into the root of this plugin. See http://github.com/quarnster/SublimeClang for more details.
I'm rookie in ubuntu OS and hope someone can give me help. Many thanks!
Following the different tutorials on the web, I have tried to make a wrapper of a c++ class in python, using SWIG.
My class looks like this:
/*file libraryInstance.h*/
struct LibraryInstance
{
void init();
void terminate();
private:
std::shared_ptr<AnObject> m_spAnObject;
};
For python exposition, I made this .i file:
%module LibraryInstance
%{
#include "libraryInstance.h"
%}
%include "libraryInstance.h"
then I have executed the command swig -c++ -python -o ./src/libraryInstance_wrap.cpp ./src/libraryInstance.i
without any output errors, swig has generated two files, libraryInstance_wrap.cpp and LibraryInstance.py
Then I compile the c++ files, including the libraryInstance_wrap.cpp. All compiles fine and I get my library .so file.
when I look into the swig generated LibraryInstance.py, I can clearly see the class LibraryInstance:
cf. entire generated python wrapper here.
But when I launch the command python LibraryInstance.py, in the same directory as my .so I see this error output:
Traceback (most recent call last):
File "LibraryInstance.py", line 26, in <module>
_LibraryInstance = swig_import_helper()
File "LibraryInstance.py", line 18, in swig_import_helper
import _LibraryInstance
ImportError: No module named _LibraryInstance
And when I look in the code of LibraryInstance.py, it just looks as if there has been an exception ImportError thrown, the the module cannot be found by python. ( line 18 ).
Any idea what should I do to correct this ?
In SWIG documentation, paragraph 31.2.2 it is stated that the name of the library .so should be _NameOfTheModule.so
So I have renammed my library _LibraryInstance.so, instead of LibraryInstance.so... and now my module loads fine.
How do you get started running (and debugging) a C++/Python combined project?
So far I've started with the basics:
Checking out the project from source (http://code.google.com/p/pyv8/source/checkout)
Copying a helloworld.py example into the directory with PyV8, so it can import PyV8.
This doesn't work, of course:
Traceback (most recent call last):
File "helloworld.py", line 4, in <module>
import PyV8
File "C:\Users\Default User\Documents\pyv8-read-only\PyV8.py", line 32, in
<module>
import _PyV8
ImportError: No module named _PyV8
The next step is probably to compile the cpp files and somehow make them available to Python as a library, but I'm not sure how to do that from the command line. There appears to be a VS project but I don't have Visual Studio.
(It would be way more awesome if anyone could also figure out how to debug both the C++ and Python parts in Eclipse)
Help! Thanks.