All Questions
50 questions
2
votes
5
answers
135
views
Segmentation fault when executing a Python script in a C program?
I need to execute some python and C at the same time.
I tried using Python.h:
#include <Python.h>
int python_program(char* cwd)
{
char* python_file_path;
FILE* fd;
int run;
...
3
votes
1
answer
559
views
Why does Linux fail to map this PT_LOAD ELF segment?
I'm trying to embed arbitrary data into an ELF executable and have Linux map it in automatically at load time. Recently asked another question about this which culminated in support for this use case ...
3
votes
1
answer
129
views
Embedded Python in C program seg faults when ran from script in python
I wrote a short program trying to embed python into it
(according to the C Python Api docs : https://docs.python.org/3/extending/embedding.html):
#include <python3.8/Python.h>
#include <stdio....
1
vote
0
answers
155
views
struct "_typeobject" has no field "tp_name" in Cython Example
I'm trying to learn how to Embedd Cython modules in c Applications from the Cython Website, I have Literally copy pasted the entire example and it doesn't work. it gives me a struct "_typeobject&...
0
votes
1
answer
155
views
cannot run Py_Initialize(), application exited with code -1073741191
I'm currently testing around with embedding Python in a C application, however I couldn't get it to work at all. I can build it just fine, but running it returns no error, only the Application error ...
0
votes
1
answer
407
views
Embedding Lua 5.1 in C, Can't Debug, Prelaunch Task Error in VSCode
I'm trying to see how to embed Lua 5.1 into a C file in order to create a minimum reproducible example to try and solve another problem (thread here). I was following this simple tutorial but as soon ...
0
votes
0
answers
2k
views
How to rectify unknown type name 'PyTypeObject' error when using Python.h?
I used Python.h to write the following program
#include <stdio.h>
#include <Python.h>
int main()
{
return 0;
}
i get the following error
81 1 C:\Program Files (x86)\Dev-Cpp\...
1
vote
1
answer
362
views
how to call c function which is of type static pyobject inside c
I want to call a function of static PyObject type which I described inside my c program in the inside of that that c program. How to call this function? What will be the (Pyobject self) argument? I ...
1
vote
1
answer
645
views
Embedding Python into C - can't import method from python module
I'm building C application which will be using Python plugins. When trying to call the method from another Python module, the function PyImport_ImportModule() seems to imports the module properly, ...
1
vote
0
answers
199
views
How to pass multidimensional array from C to embedding python function
This maybe asked before, but I need more clarification.
I am working on a project where I need to send a 3D array from C to the embedded Python function.
I referred this, but couldn't get it to ...
3
votes
1
answer
433
views
"Embedding" a folder into a C/C++ program
I have a script library stored in .../lib/ that I want to embed into my program. So far, that sounds simple: On Windows, I'd use Windows Resource Files - on MacOS, I'd put them into a Resource folder ...
1
vote
0
answers
524
views
Embedding Python in C under Windows
I want to compile a .c file containing a Header Python.h using minGW on Windows 10. My Goal is to embedd some pythoncode in C an this is just a little test for the compiling.
My sourcefile looks as ...
0
votes
0
answers
58
views
Embedding Python in C, handing over a long list to python function
I have got a python function in which a neuronal network is implemented to process some image data and I got a simulation software which is written in C, so my goal is to embed the python function in ...
2
votes
0
answers
164
views
Turn embedded python into jupyter kernel?
I am having a code in c++ which embeds Python. I would like the Python interpreter accessible thorugh Jupyter console (qt or browser) for which I need to run kernel first. Is it possible to make the ...
12
votes
1
answer
1k
views
Call Racket function from C
I have a Racket module hw.rkt:
#lang racket/base
(provide hw)
(define (hw) (displayln "Hello, world!"))
I would like to write a C program that embeds the Racket runtime and applies the procedure (...
1
vote
2
answers
375
views
python embedding in C : define the python script as a C string?
I would like to invoke the following python script in C :
#!/usr/bin/python2.7
import parser
def evaluate(text):
code = parser.expr(text).compile()
return eval(code)
as explained in the ...
1
vote
0
answers
138
views
Python parse embedding in c
I'm trying to embedding two python functions in C code. My problem is that I can't parse None py object to NULL in C.
I created a "check.py" file within it:
def integer(s):
a = input(s)
try:...
2
votes
0
answers
199
views
Making global variables available to script parsed with perl_parse
I'm working on the rlm_perl module for the FreeRADIUS project. This module handles marshalling/unmarshalling of attribute value pairs to/from a perl interpreter. It allows AAA policies to be written ...
1
vote
1
answer
2k
views
Catch an exception in embedded mono
MonoObject * pException = NULL;
// this method will cause an exception in c#, something like null exception
MonoString * pResult = (MonoString*) mono_runtime_invoke(g_pGetMethod, NULL, monoargs, &...
7
votes
1
answer
3k
views
Embedding Python: No module named site
I'm embedding python in a C application. I have downloaded the standard python dist and placed it relative to program and used this to link & build the C application.
This works fine on my devel ...
4
votes
1
answer
228
views
Linking to python 2.7 from C on Linux
Hello I am having problem linking my .so file t Python on Linux systems. (I got this working just fine on MacOS X and Windows but am stuck on this)
Currently the link flags are as follows:
LIBS = -...
1
vote
1
answer
506
views
Extension Python by C++: How to determine python function name on C callback
I have extension of Python by C++ with Python API.
There is one c function handler for different python functions.
How in the c function handler I can determine a python function which called me?
...
3
votes
1
answer
785
views
Cython in C/C++
I have been using Cython on a couple of projects. I see a lot of documentation on including C++ and C into your cython code. Sometimes when I am extending an existing C/C++ project I feel the urge to ...
26
votes
1
answer
14k
views
luaL_openlib replacement for Lua 5.2
I am adapting a library written for Lua < 5.2 and got to a call I don't know the equivalent of:
luaL_openlib(L, "Polycore", polycoreLib, 0);
Where polycoreLib is a
static const struct luaL_Reg ...
1
vote
0
answers
72
views
Embedding python classes with different input function to C
So, I have followed the instructions from here.
I changed several parts because I want to access many classes in python codes with different functions.
For learning, I modified the codes from the link ...
10
votes
2
answers
782
views
Where is documentation on the embedding API for the Ruby interpreter? [closed]
I am looking for a comprehensive, online, documentation resource regarding the embedding of the Ruby interpreter into C or C++ programs, and the API(s) for that purpose.
The section on this in the ...
-1
votes
3
answers
5k
views
how to read values from a structure in C
#include<stdio.h>
#define msize 4096
struct memory
{
int a[msize];
};
void main()
{
struct memory m;
m.a[0]=250; // temperature value of 25,0
m.a[4]=01; // heater status OFF
...
11
votes
2
answers
1k
views
Does embedding c++ code in python make your python application faster? [closed]
Does embedding c++ code in python using ctypes, boost.python, etc make your python application faster?
Suppose I am making an application in pygtk and I need some functions which need to be fast. So ...
0
votes
2
answers
689
views
Embedding Python 3.3
I try to embed Python 3.3, as described here.
I'm on MacOS 10.8 which has Python 2.7 so I downloaded binary distribution of version 3.3 from python.org. From it I got all the headers and "Python" ...
5
votes
1
answer
572
views
create new None object in embedded python
I am writing a simple C wrapper for a Python module. What I need to do is create a new PyObject* that represents None. I can't figure out how to do this. Is there a simple function that will return ...
0
votes
4
answers
2k
views
C/C++ embedding python module PIL, the python function want to return all pixel data, but i why can't?
add c/c++ code embedding python. all problem is in c code, I don't known how to get the pixel value.
python code:
import Image
format = ""
mode = ""
size = ""
data = list()
def getImage(file):
...
7
votes
1
answer
9k
views
attempt to call global `print' (a nil value)
I have the following C file:
//thing.c
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <stdio.h>
lua_State* L;
int main(){
L = lua_open();
...
2
votes
1
answer
2k
views
Unloading Mono domains in multithreaded context
I have a multithreaded application that activate multiple Mono domains from native code.
Each domain has it's own thread.
I use the following code to activate a domain:
///Create a new domain.
...
1
vote
1
answer
1k
views
How to embed CINT into a C++ app on Windows?
I would like to know how to embed CINT into a C++ code on Windows 7 or NT.
On windows7, I need to write a C++ program that reads a C++ program from an input file, runs it and counts how many lines of ...
5
votes
1
answer
3k
views
Does the Python 3 interpreter leak memory when embedded?
This bug report states that the Python interpreter, as of June 2007, will not clean up all allocated memory after calling Py_Finalize in a C/C++ application with an embedded Python interpreter. It was ...
2
votes
1
answer
285
views
Cross Platform NPAPI Interfacing/Integrating
I would like to use Google Earth in one of my cross platform C++ applications, and the only way I can see that would allow me to integrate it nicely into my GUI and interface to it using it's ...
5
votes
2
answers
7k
views
Is it possible to embed nginx in a C/C++ application
The application runs in Linux, Windows, Macintosh.
Also, if yes, how much effort is required?
6
votes
2
answers
1k
views
Recommended way to embed JVM in C program with NO library?
What's the recommended way to embed JVM in C program with NO library. This means JVM as a eDSL execution engine. (Not whole Java platform environment) I'm trying to use another JVM based language ...
1
vote
1
answer
1k
views
Error when starting a new thread and opening dialog using Mono API
I'm working on a Native dll written in C++ that uses mono to show a graphical user interface. I've written a simple skeleton, it works but I get an error under certain conditions.
First here is the C#...
7
votes
2
answers
602
views
(Embedding Mono) Parallel activation of domains
I'm wondering if it's possible to activate multiple Mono domains and execute them in parallel from native code:
I use the following code to activate a domain:
///Create a new domain.
m_domain = ...
4
votes
3
answers
2k
views
Loading DLL from embedded python code in c
The crux of my problem is this:
I am developing code on Windows XP in C with MS Visual Studio 10.0, and I need to embed Python to do some plotting, file management, and some other things. I had ...
33
votes
11
answers
13k
views
Tiny javascript implementation? [closed]
I need an extremely tiny implementation of (maybe a subset of?) Javascript. Code size and memory usage are extremely important (speed isn't in the question, it can run as slow as it likes). It must be ...
0
votes
3
answers
538
views
What HTTP header is needed to be returned so web browsers use the suggested filename? (File download from CGI in C)
We have a PDF file download link on a web page with a C language CGI program actually passing on the file from our embedded device's web server. The web server is custom coded because of severe memory ...
1
vote
2
answers
1k
views
Embedding Python in C for configuration files
I'm trying to embed python into c to use it for configuration:
If I do it like this:
/******************************************************************************
*
* Embeding Python Example
*
* ...
2
votes
5
answers
696
views
Embeddable formula interpreter
I need something to embed in my C/C++ program to interpret formulas of the like x*log(x) or sin(x). I would like something small and simple, otherwise I can just embed Python, or Ch, or Scheme, or you ...
6
votes
2
answers
5k
views
Embedding Python in C: Having problems importing local modules
I need to run Python scripts within a C-based app. I am able to import standard modules from the Python libraries i.e.:
PyRun_SimpleString("import sys")
But when I try to import a local module can
...
1
vote
1
answer
723
views
Embedding Python and adding C functions to the interpreter
I'm currently writing an applications that embedds the python interpreter. The idea is to have the program call user specified scripts on certain events in the program. I managed this part but now I ...
38
votes
3
answers
35k
views
How to embed WebKit into my C/C++/Win32 application?
The solutions I have found are irrelevant:
someone used WebKit in a Delphi project
someone used it with Java
there is QtWebKit (about:blank demo app takes 44 megs)
.Net port of it
GTK+ port
I need a ...
0
votes
2
answers
289
views
is it possible to call python methods from a C program?
I remember seeing somewhere that you could call python methods from inside C using
#include "python.h"
But I can't seem to find the source for this or any examples.
How can I call python methods ...
7
votes
3
answers
15k
views
How to convert a C string (char array) into a Python string when there are non-ASCII characters in the string?
I have embedded a Python interpreter in a C program. Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e....