my code:
main.cpp
#include <Python.h>
int main(int argc, char **argv)
{
Py_Initialize();
FILE *file_1 = fopen("a2l_reader.py","r+");
PyRun_SimpleFile(file_1,"a2l_reader.py");
Py_Finalize();
}
compile under windows using MinGW:
g++ main.cpp libpython25.a -o a
no error was found. But when I run a.exe the program just crashes.
What should I do? 5 10547
On 9¤ë24¤é, ¤È«á3:39, lixinyi...@gmail.com wrote:
my code:
main.cpp
#include <Python.h>
int main(int argc, char **argv)
{
Py_Initialize();
FILE *file_1 = fopen("a2l_reader.py","r+");
PyRun_SimpleFile(file_1,"a2l_reader.py");
Py_Finalize();
}
compile under windows using MinGW:
g++ main.cpp libpython25.a -o a
no error was found. But when I run a.exe the program just crashes.
What should I do?
PyRun_File and PyRun_SimpleFile would just crash my application.
but PyRun_SimpleString works fine.
But why??? li********@gmail.com <li********@gmail.comwrote:
my code:
main.cpp
#include <Python.h>
int main(int argc, char **argv)
{
Py_Initialize();
FILE *file_1 = fopen("a2l_reader.py","r+");
PyRun_SimpleFile(file_1,"a2l_reader.py");
Py_Finalize();
}
compile under windows using MinGW:
g++ main.cpp libpython25.a -o a
no error was found. But when I run a.exe the program just crashes.
What should I do?
Run it under gdb (which should have come with MinGW).
Check that you actually opened the file, ie file_1 != 0.
This might be relevant http://effbot.org/pyfaq/pyrun-simple...n-unix-why.htm
--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
On Sep 24, 6:30*am, Nick Craig-Wood <n...@craig-wood.comwrote:
lixinyi...@gmail.com <lixinyi...@gmail.comwrote:
*my code:
*main.cpp
*#include <Python.h>
*int main(int argc, char **argv)
*{
*Py_Initialize();
*FILE *file_1 = fopen("a2l_reader.py","r+");
*PyRun_SimpleFile(file_1,"a2l_reader.py");
*Py_Finalize();
*}
*compile under windows using MinGW:
*g++ main.cpp libpython25.a -o a
*no error was found. But when I run a.exe the program just crashes.
*What should I do?
Run it under gdb (which should have come with MinGW).
Check that you actually opened the file, ie file_1 != 0.
This might be relevant
*http://effbot.org/pyfaq/pyrun-simple...dows-but-not-o....
--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
There's a workaround.
filename = "Entire path of the python file";
PyObject* PyFileObject = PyFile_FromString(filename, "r");
PyRun_SimpleFile(PyFile_AsFile(PyFileObject), filename);
// decref PyFileObject http://mail.python.org/pipermail/pyt...ch/431725.html http://python-forum.org/pythonforum/...&t=1554&p=6567
On Sep 24, 11:05*am, "Aaron \"Castironpi\" Brady"
<castiro...@gmail.comwrote:
On Sep 24, 6:30*am, Nick Craig-Wood <n...@craig-wood.comwrote:
lixinyi...@gmail.com <lixinyi...@gmail.comwrote:
*my code:
*main.cpp
*#include <Python.h>
*int main(int argc, char **argv)
*{
*Py_Initialize();
*FILE *file_1 = fopen("a2l_reader.py","r+");
*PyRun_SimpleFile(file_1,"a2l_reader.py");
*Py_Finalize();
*}
*compile under windows using MinGW:
*g++ main.cpp libpython25.a -o a
*no error was found. But when I run a.exe the program just crashes.
*What should I do?
Run it under gdb (which should have come with MinGW).
Check that you actually opened the file, ie file_1 != 0.
This might be relevant
*http://effbot.org/pyfaq/pyrun-simple...dows-but-not-o...
--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
There's a workaround.
filename = "Entire path of the python file";
PyObject* PyFileObject = PyFile_FromString(filename, "r");
PyRun_SimpleFile(PyFile_AsFile(PyFileObject), filename);
// decref PyFileObject
http://mail.python.org/pipermail/pyt...&t=1554&p=6567
Just to follow up-- The links say that the crash comes from opening a
file with two different versions of a library. Would it be possible
to get an API entry point to the version the build uses?
It does use the 'fopen' function by name, but not the same version.
And creating the entire object just to get its f_fp field is really
long.
On 9¤ë25¤é, ¤È«e1:05, "Aaron \"Castironpi\" Brady" <castiro....@gmail.com>
wrote:
On Sep 24, 6:30 am, Nick Craig-Wood <n...@craig-wood.comwrote:
lixinyi...@gmail.com <lixinyi...@gmail.comwrote:
my code:
main.cpp
#include <Python.h>
int main(int argc, char **argv)
{
Py_Initialize();
FILE *file_1 = fopen("a2l_reader.py","r+");
PyRun_SimpleFile(file_1,"a2l_reader.py");
Py_Finalize();
}
compile under windows using MinGW:
g++ main.cpp libpython25.a -o a
no error was found. But when I run a.exe the program just crashes.
What should I do?
Run it under gdb (which should have come with MinGW).
Check that you actually opened the file, ie file_1 != 0.
This might be relevant
http://effbot.org/pyfaq/pyrun-simple...dows-but-not-o....
--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
There's a workaround.
filename = "Entire path of the python file";
PyObject* PyFileObject = PyFile_FromString(filename, "r");
PyRun_SimpleFile(PyFile_AsFile(PyFileObject), filename);
// decref PyFileObject
http://mail.python.org/pipermail/pyt...&t=1554&p=6567
Wow this one works fine for me.
Thank you! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Susanne |
last post by:
Hello!
In have embedded python into my MFC application.
It works fine using the PyRun_SimpleString method, giving it a string with
some simple commands.
When i am using PyRun_SimpleFile...
|
by: Steve D. |
last post by:
I recently installed VS.NET 2003
After opening a project and leaving it open, after a certain period of time
it crashes. It only does this when a project is open. The project that I've
tried...
|
by: Rob Ristroph |
last post by:
Hi,
It's pretty unhelpful to post "I have a huge piece of code that
crashes in strange places, what's the problem?" but that's basically
my problem and I really am at my wit's end.
The piece...
|
by: Paul |
last post by:
Hi,
Global operator new and delete are overloaded and I am using stl map
to store pointers, but this code crashes, can some one shed some
light???
Compiler: MS VC++ 6.0
STL: Shipped with...
|
by: greeningster |
last post by:
I have written an application in Visual C++ for a customer but it seems
to crash randomly.
Could anyone give me any help on how I could track this down ?
Also, there appears there might be...
|
by: rogsonl |
last post by:
The latest versoin of Microsoft Visual Studio 2005 (Version 8.0.50727.42
RTM.050727-4200 Microsoft .NET Framework Version 2.0.50727) crashes very
often in debug.
1. If you modify a case statement...
|
by: walterbyrd |
last post by:
I like to develop on my desktop, then when I get stuff working, I copy
to my web-site.
I set up a new version Xampp on my windows-2k desktop. And downloaded
the stuff from the website to edit....
|
by: yinglcs |
last post by:
Hi,
I have a c++ application which crashes in this line (from the debugger,
I have a segmentation fault here):
void *object = dynamic_cast<void>(aObject);
I have stepped thru the code in...
|
by: z |
last post by:
I use Visual C 2005 to develop my programs. One in particular is
crashing in very specific and hard to replicate situations, made worse
by the fact it only crashes when run -outside- the dev - as...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
| |