473,378 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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="noddy", *filename="no_real_file";
PyObject *tmp;

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

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

Regards,
Vio
Jul 18 '05 #1
0 1127

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

Similar topics

2
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...
5
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++...
3
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...
4
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,...
11
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...
1
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...
5
by: James | last post by:
I heard C is better for programming embedded systems than C++? Is this true, if so why?
3
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...
1
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. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.