473,778 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Swig-Python problems

Hi, I've got a problem with SWIG and Python2.2.I've installed the
SWIG1.3.21 releaseunder QNX6.2 platform .I tried to make the exemple
example.c (in the directory ../Swig/Exemple/python/simple)
/* File : example.c */

#include <time.h>
double My_variable = 3.0;

int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(&ltime);
return ctime(&ltime);
}.
After the commans:

swig -python example.i
gcc -c example.c example_wrap.c -I/usr/local/python2.2
ld -shared example.o example_wrap.o -o _example.so

I use Python module as follows
import example


and I've got the message: "Memory falut (core dumped)"
What can I do??
Jul 18 '05 #1
3 1912
In article <cd************ **************@ posting.google. com>, matteo wrote:
Hi, I've got a problem with SWIG and Python2.2.I've installed the
SWIG1.3.21 releaseunder QNX6.2 platform .I tried to make the exemple
example.c (in the directory ../Swig/Exemple/python/simple)
/* File : example.c */

#include <time.h>
double My_variable = 3.0;

int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(&ltime);
return ctime(&ltime);
}.
After the commans:

swig -python example.i
gcc -c example.c example_wrap.c -I/usr/local/python2.2
ld -shared example.o example_wrap.o -o _example.so

I use Python module as follows
import example


and I've got the message: "Memory falut (core dumped)"
What can I do??


I've found on Linux that it's easy to run the entire Python interpreter
under a debugger. I'm not familiar with the tools on QNX, but I would
add "-g" to the gcc line (to add debugging symbols), and then run "gdb
python", so that when the program crashes you can see exactly where.

(If you're not familiar with gdb, type "run" at the first prompt, and
then use the interpreter as normal, and when the crash happens and you
get back to the gdb prompt, type "bt" to get a backtrace. This should
be all you need to get started.)

Joe
Jul 18 '05 #2
m.*******@itia. cnr.it (matteo) wrote in message news:<cd******* *************** ****@posting.go ogle.com>...
Hi, I've got a problem with SWIG and Python2.2.I've installed the
SWIG1.3.21 releaseunder QNX6.2 platform .I tried to make the exemple
example.c (in the directory ../Swig/Exemple/python/simple)
/* File : example.c */

#include <time.h>
double My_variable = 3.0;

int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(&ltime);
return ctime(&ltime);
}.
After the commans:

swig -python example.i
gcc -c example.c example_wrap.c -I/usr/local/python2.2
At first ... please use qcc and not gcc.

qcc -c -fPIC example.c example_wrap.c -I/usr/local/python2.2

should work ...
ld -shared example.o example_wrap.o -o _example.so

I use Python module as follows
>>> import example


and I've got the message: "Memory falut (core dumped)"
What can I do??


... use Pyrex :)

Armin Steinhoff
Jul 18 '05 #3
matteo wrote:
Hi, I've got a problem with SWIG and Python2.2.I've installed the
SWIG1.3.21 releaseunder QNX6.2 platform .I tried to make the exemple
example.c (in the directory ../Swig/Exemple/python/simple)
/* File : example.c */

#include <time.h>
double My_variable = 3.0;

int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}

int my_mod(int x, int y) {
return (x%y);
}

char *get_time()
{
time_t ltime;
time(&ltime);
return ctime(&ltime);
}.
After the commans:

swig -python example.i
gcc -c example.c example_wrap.c -I/usr/local/python2.2
ld -shared example.o example_wrap.o -o _example.so

I use Python module as follows
>>> import example


and I've got the message: "Memory falut (core dumped)"
What can I do??


What does your interface space file (examplei.i) contain?

Jul 18 '05 #4

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

Similar topics

2
4781
by: Matt Whelan | last post by:
Supposedly, recent versions of SWIG can be made to work with MS VC++'s non-standard integer data types. According to a recent SWIG ChangeLog entry: %apply long long { __int64 }; should make Swig happy. But it doesn't. I get Syntax Errors on each line where __int64 appears. Am I missing something? I'm new to SWIG (but not to Python or C++).
3
2816
by: Kevin Dahlhausen | last post by:
Could anyone post a simple setup.py script that uses a SWIG interface to C++ code and the mingw compiler? I followed some online samples, and am using the setup.cfg file to specify swig-c++=1. Trying to build using mingw out of the cygwin environment but the final call to link the extension calls directly to 'cc' which I think should really be g++ at that point.
19
2506
by: Thomas Heller | last post by:
ctypes 0.9.2 released - Oct 28, 2004 ==================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call functions exposed from dlls/shared libraries and has extensive facilities to create, access and manipulate
1
1942
by: Philip Smith | last post by:
Does anyone use SWIG????? I'm having trouble patching it to allow me to compile wrappers in Borland C++ Builder because Borland will insist on adding underscores to symbols. Turn this off and it won't link the Python library. The answer is to declare init_function and any other exported functions as __stdcall. Easy enough to patch the SWIG file for the init_function but I can't for the life of me see how to automate this process for...
0
1290
by: peter.o.mueller | last post by:
Hi together, i have a Windows DLL in C that is internally multithreaded and provides a callback function to signal specific events. As I understood one can use "normal" C-code with swig. Is it also possible to use existing DLLs? Does swig can also handel the callback method? If not - is there another wrapper toolkit that can do that? Thanks, Peter
6
2552
by: None | last post by:
Hi, I was trying to use SWIG to expose some C++ functions to perl. But, I ran into some issues here. I don't know why, but I see that a macro in SWIG replaces "NORMAL" with "PL_op->op_next"... I ran the following test: Files:
0
1675
by: Jazi | last post by:
I would appreciate if someone can help me dealing with wrapping java around c++ using SWIG. I have wrapped simple classes without any problem but I had some difficulties getting a vector function working. Here is what I have. I have two classes in C++; Fold class and Subs class. In the Subs class there is a method called get_all_folds that returns a vector of Fold objects. I compiled my c++ code and wrote a c++ driver and everything works...
2
3581
by: piyushtiwari | last post by:
I have to call a C++ function in php. I tried it using swig. I wrote the interface file example.i to call the functions from example.cxx in php. To build a PHP extension, I run swig using the -php option as follows: ~$ swig -php example.i This produced 3 files example_wrap.c, php_example.h and example.php. Now to build the extension as a dynamically loaded module I used cc -I.. $(PHPINC) -fpic -c example_wrap.c ...
1
1210
by: jiangfan | last post by:
Dear All, I am new to SWIG, and I tried to search the SWIG mailinglist for my specific question, but I did not find it. And for a simple one c++ file, I can handle it successfully. Now I have a small project including several C files, file1.C file2.C file3.C file2.h file3.h , file1.C is the main() entry for my project, and file1.C has the following include statements #include file2.h
3
1107
by: Anish Chapagain | last post by:
Hi.. I'm new to SWIG and need to create Wrapper for C code, so, I have installed the SWIG already but doesnot know how to run it for generating Interface file... My C code is in message.c so what do i need to do the first step..uisng SWIG..i read the documentation but cannot grasp creating interface file. thank's anish
0
9632
marktang
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...
0
9471
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,...
0
10136
jinu1996
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...
1
10071
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
9925
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
7478
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
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
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
3
2867
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.