473,662 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

importing embedded dynamic lib

Vio
I have a basic dynamic lib "noddy.so" which I want to
1- embed inside my executable
2- import by embedded python interpreter using an API call.

I have two questions:

1- what would be the recommended technique to embed a binary file inside
an executable?
My guess would be to add the binary "noddy.so" to the linking command,
but then
how do I get access to that chunk of code in my source file? My goal
would be to achieve something like

int* noddy_so = <binary here> ... but then how do I include the
binary code, or make the source code aware of it?

Using "#include" doesn't feel right, as this is a binary file, not
ASCII. And loading the file at run-time isn't right either, I need to
load it at compile time. And is "int*" the appropriate data type for
binary data?

2- Let's imagine that I managed to load "noddy.so" into my source code
somehow, and now have a pointer to it.
Any hints as to the correct python API call to import a dynamic lib
from a memory buffer? Could someone
tell me for example if the following makes sense for my purpose?

------------------------------
char *modulename="no ddy", *filename="no_r eal_file";
PyObject *tmp;

/*Here try to translate the binary lib into a PyObject*/
tmp = Py_CompileStrin g(noddy_so, filename, Py_file_input);
if (tmp == NULL)
error("Can't compile module [tmp]");

/*Import the "noddy" module*/
pmod = PyImport_ExecCo deModule(module name, tmp);
if (pmod == NULL)
error("Can't load module [pmod]");
------------------------------

Regards,
Vio
Jul 18 '05 #1
0 1144

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3503
by: Rick Olson | last post by:
I'm trying to add a Tkinter interface to an existing C program with embedded python, but seem to have trouble importing Tkinter (or accessing it). I tried a simple program that would run the script "hello.py" This is hello.py: from Tkinter import * mainWindow=Tk() label=Label(mainWindow, text="Hello") label.grid(row=0,column=0)
5
3722
by: John Benson | last post by:
Regarding the message appended below: I was in a similar situation, only I had 4 "small" (RAM-wise) legacy processors in a fault-tolerant Tandem K100 system. The system came with an old Borland C++ compiler but I didn't want to become an expert in anachronistic C++ trivia, so I ported Lua (www.lua.org) using the perfectly serviceable C compiler. Although I still need to put in library extensions to access the Tandem's Guardian OS API, Lua...
3
1994
by: stefan | last post by:
Hi Folks, I currenty extended some of my C++ functionality to python and also embedded python to use python functionality in my C++ system (and use as well these extended functions). While this works fine with the core python functionality, as soon as I run a script (on the embedded system) which tries to import modules which are not in the core system, like "xml" or "re", it fails and says it cannot find the related dll (for example...
4
4785
by: jrefactors | last post by:
I want to distinguish between static SQL, dynamic SQL, and embedded SQL, but couldn't find too much useful resources in the web. For example, if we put SQL statements (SELECT, INSERT, UPDATE, etc...) inside an application (e.g. Java application, VB application, etc...), do we consider those SQL statements as static SQL? or embedded SQL? How about dynamic SQL? any practical examples? Please advise. thanks!!
11
4253
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
1
3670
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am trying to avoid this extra step. can access read in this file directly into a table as append data? thank you very much for any pointers
5
1855
by: James | last post by:
I heard C is better for programming embedded systems than C++? Is this true, if so why?
3
5322
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file has no problems, I've done it manually with the Import Spreadsheet wizard. The worksheet has 43 rows, and I import a named range defined as "=Sheet1!$C:$E". The import works, but I get a table with 64K rows, all but 43 being blank!
1
2568
by: jmc | last post by:
The short version: Is there a way to get embedded styles to work on files that are displayed in a page using the shtml Include method? My work intranet site uses Front Page dynamic templates. Please no flames; I'm not a FP fan either but that's the only tool I'm given, and the templates coupled with css made it easy for me (and others) to update the site "wrapper" and menu quickly when adding pages, as the website is close to the...
0
8343
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,...
1
8545
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,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
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...
0
5653
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();...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.