Hello, all,
I am not sure if this is the right place to ask, but could you kindly
tell me how to "load" a shared object (like libx.so) into python, so
that the methods in the .so can be used? That too, given that the shared
object was written in c++, compiled with g++ ?
Thanks,
Pro Grammer 3 2025
On Tue, 25 Jan 2005 23:19:01 +0200, Pro Grammer <a@b.c> wrote: Hello, all, I am not sure if this is the right place to ask, but could you kindly tell me how to "load" a shared object (like libx.so) into python, so that the methods in the .so can be used? That too, given that the shared object was written in c++, compiled with g++ ?
Will ctypes do the trick? http://starship.python.net/crew/theller/ctypes/
--
Cheers,
Simon B, si***@brunningo nline.net, http://www.brunningonline.net/simon/blog/
Pro Grammer <a@b.c> writes: Hello, all, I am not sure if this is the right place to ask, but could you kindly tell me how to "load" a shared object (like libx.so) into python, so that the methods in the .so can be used? That too, given that the shared object was written in c++, compiled with g++ ? Thanks, Pro Grammer
Will the dl standard library module help you? From the Python docs at: http://docs.python.org/lib/module-dl.html
Example: import dl, time a=dl.open('/lib/libc.so.6') a.call('time'), time.time()
(929723914, 929723914.498)
I'm guessing that there might be some C++ issues, but maybe it's worth
looking into.
Rick
On Jan 28, 2005, at 6:48 AM, Rick L. Ratzel wrote: Pro Grammer <a@b.c> writes:
Hello, all, I am not sure if this is the right place to ask, but could you kindly tell me how to "load" a shared object (like libx.so) into python, so that the methods in the .so can be used? That too, given that the shared object was written in c++, compiled with g++ ? Thanks, Pro Grammer Will the dl standard library module help you? From the Python docs at:
http://docs.python.org/lib/module-dl.html
As Simon Brunning notes, ctypes
(<http://starship.python .net/crew/theller/ctypes/>) is a robust
alternative to the `dl' module.
Example:
import dl, time a=dl.open('/lib/libc.so.6') a.call('time'), time.time() (929723914, 929723914.498)
A note about this example: the `dl' call returns an integer as that is
what the C time function returns. time.time() in Python is implemented
in terms of C's gettimeofday, ftime or time depending on the platform.
I'm guessing that there might be some C++ issues, but maybe it's worth looking into.
As far as I am aware, neither dl nor ctypes natively support C++. This
is a tricky matter, due to the lack of standards for C++ ABI's covering
name mangling and vtable layout etc. See the thread starting at
< http://mail.python.org/pipermail/pyt...2004-November/
249513.html> for more information.
Regards,
Mark Rowe
<http://bdash.net.nz/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: keefah |
last post by:
Hi,
I can't seem to get past this problem, though I've tried multiple examples
off the web. I've registered integrated Crystal (VS.NET 2003 Pro). I've made
sure the assemblies are all there. I've tried design-time ReportSource
assignment and runtime. Why can't I get past this? Below is error page from
most basic of tries (just a dumb (text only) report within a viewer on a
webform. Thanks in advance, -Nick
Description: An unhandled...
|
by: santa19992000 |
last post by:
Confusing th eword with "library", "shared library" and how to use
these things in real C project, is there any small example I can take a
look. Thanks.
|
by: Lauchlan M |
last post by:
Hi.
I'm using ASP.NET, getting an "Object reference not set to an instance of an
object" error.
In my login.aspx page I have:
string arrUserRoles = new string {"UserRole"};
Context.Items.Add("UserRoles", arrUserRoles);
Context.User = new
|
by: Jeff_Mac |
last post by:
Hi there. I'm a bit of a newbie, and I would appreciate any help that
anyone can give me on an error I'm getting with Crystal Reports.
Every time I attempt to view a report using the Crystal Report Viewer,
I get a "Load Report Failed" error, and I'm not sure what I can do to
resolve it.
I know it's not the connection to the data -- I'm able to get a
datagrid to display the data just fine after filling a dataset. I
tried searching the...
|
by: Dominique Vandensteen |
last post by:
I want to dynamicly load a type (typename is defined in the database).
This type is located in the exe itself or one of the dll's in the directory
with the exe file.
When creating an instance directly it works, when using reflection none of
the dll's is "scanned".
I used following code to work around this problem.
Now I just want to know if this is the/a good way to do it, or should I use
another system.
| |
by: Kenneth Kahl |
last post by:
Hello,
I would like to call a C++ programm out of Java with help of JNI. By the
followed command I created a "shared library":
g++ -shared -o libcalculate.so rechner.cpp
When I create an object from the existing program inside a method of my
class rechner.cpp, and then call the method out of java, a following
|
by: lister |
last post by:
Hi all,
I have a fairly diverse range of data that I want to cache in the
session rather than pulling it from the database on every page
refresh.
The problem is is that it seems that PHP requires the class
definitions available on EVERY page, as it unserialises everything
even if it's not going to be used.
|
by: Michel Couche |
last post by:
Hello,
I have an ASP.Net application that uses the Wizard control to build a newsletter.
There are three steps in the wizard.
The customer's specific design data are loaded from a database in step 1 of the wizard and saved into a session variable.
In step 2, when the user clicks on a button, I load the design data from the session variable and these are saved for further handling in a HashTable.
The HashTable is defined in the...
|
by: =?Utf-8?B?SkhhbGV5?= |
last post by:
Our system is:
IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram
Windows Server 2003 SP2
IIS 6.0
SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server)
Windows Server 2003 SP2
SQL Server 2000
We are having some problems with a website we are developing, and had some
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |