Dynamic linking and Python SWIG (C++) works in C++ fails in python -
I have a library for which I have created Python Cover using SWIG. The library accepts tasks provided by the user, which is in a dynamically linked .so file. At the moment I am working with one that I have created myself and has been working on dynamic linking in C ++ . When I try to run it in Python, I get undefined symbol errors. These are the symbols that are not present in the provided file. But the files are present in the main program (essentially these are the tasks that allow the provided module access to the main program data).
I do not get any error in running a short test program in C ++, but with this cover a small test program (which used to work before) fails in Python. I can not think of an explanation because it may fail in C ++ and not in the Python. I'm a little worried that C ++ is not working properly, but I'm not telling, and Python C ++ is not raising errors. Still the results obtained by C ++ are accurate, so it seems impossible.
Any idea how this is possible and so how can I fix it?
Thank you.
Update: I have added this code to the top of the program:
import DL sys.setdlopenflags (dl.RTLD_NOW | dl.RTLD_GLOBAL)
< / Pre>This is freed from runtime error, but unfortunately allows another problem (due to linking it still). The work that is being dynamically called from within the connected library which is part of the main program, they are not returning the right value. They are returning 0. And is it obvious that they are not even running at all. The question is, what is actually going on, why is it different for C ++, and how can I fix it?
Thanks again
Update - A possible explanation Python imports module, which is my C ++ library which is wrapped by SWIG. This C ++ library uses Duplication and Dlsm to get the functions given to the user. That is why the file user provided a file call to the works that is part of the C ++ Library function .so file Calling in a C ++ library is failing, which fails to call the function and just returns 0. However this failure occurs when the test code is written in Python. The C ++ test code that uses the library works fine.
A solution is to ensure that Python is preloading the C ++ main library in the global area, this is a lot That's not the only beautiful solution, and I do not want to do this, but it works for the moment.
After poking and validating the LD_LIBRARY_PATH environment variable after a while, I have to set up whenever I start the terminal to search the main C ++ library which has been switched. So, I saw the LD-PREOD environment variable that worked on setting the main C ++ Library file name.
I doubt because it can be used to "selectively override tasks in other shared libraries".
If any environment gives a better answer than setting the environment, it is not certain how it is portable.
Edit: The basic problem is that the users made available to the library are not visible in the global scope
Success!
P> HTML>
Comments
Post a Comment