Hi Everyone,
Recently I have been working on building a module for Python from C++
code, with SWIG, and towards the end of compiling the various sets of
code I'm getting an error. The compiling error comes up when using g+
+.
================================================== =====
[comp:~/swig_project] user% swig -c++ -python example.i
[comp:~/swig_project] user% g++ -c example.cpp
[comp:~/swig_project] user% g++ -c example_wrap.cxx -I/scisoft/i386/
Packages/Python-2.4.3/Python.framework/Versions/2.4/include/python2.4/
example_wrap.cxx: In function 'PyObject* _wrap_main(PyObject*,
PyObject*)':
example_wrap.cxx:735: error: 'main' was not declared in this scope
================================================== =====
The beginning of example.i looks like the following:
================================================== =====
%module filename
%{
#define file_plugin "plugins/file.h"
#if foo_OS!=2
#include <pthread.h>
#endif
#include "../Foo.h"
using namespace foo_library;
%}
================================================== =====
The error that is being picked up in reference to 'main' is contained
in the following excerpt, generated by SWIG (example_wrap.cxx):
================================================== =====
/*-----------------------------------------------
@(target):= _filename.so
------------------------------------------------*/
#define SWIG_init init_filename
#define SWIG_name "_filename"
#define cimg_plugin "plugins/file.h"
#if foo_OS!=2
#include <pthread.h>
#endif
#include "../Foo.h"
using namespace foo_library;
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_main(PyObject *self, PyObject *args) {
PyObject *resultobj;
int arg1 ;
char **arg2 = (char **) 0 ;
int result;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"iO:main",&arg1,&obj1)) goto
fail;
if ((SWIG_ConvertPtr(obj1,(void **) &arg2,
SWIGTYPE_p_p_char,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
result = (int)main(arg1,arg2);
resultobj = PyInt_FromLong((long)result);
return resultobj;
fail:
return NULL;
}
================================================== =====
Any clues as to what is happening here or what to do next? If you
know, your help would greatly help. Thanks in advance! 1 1922 br******@gmail.com wrote:
Hi Everyone,
Recently I have been working on building a module for Python from C++
code, with SWIG, and towards the end of compiling the various sets of
code I'm getting an error. The compiling error comes up when using g+
+.
================================================== =====
[comp:~/swig_project] user% swig -c++ -python example.i
[comp:~/swig_project] user% g++ -c example.cpp
[comp:~/swig_project] user% g++ -c example_wrap.cxx -I/scisoft/i386/
Packages/Python-2.4.3/Python.framework/Versions/2.4/include/python2.4/
example_wrap.cxx: In function 'PyObject* _wrap_main(PyObject*,
PyObject*)':
example_wrap.cxx:735: error: 'main' was not declared in this scope
================================================== =====
The beginning of example.i looks like the following:
================================================== =====
%module filename
%{
#define file_plugin "plugins/file.h"
#if foo_OS!=2
#include <pthread.h>
#endif
#include "../Foo.h"
using namespace foo_library;
%}
================================================== =====
The error that is being picked up in reference to 'main' is contained
in the following excerpt, generated by SWIG (example_wrap.cxx):
================================================== =====
/*-----------------------------------------------
@(target):= _filename.so
------------------------------------------------*/
#define SWIG_init init_filename
#define SWIG_name "_filename"
#define cimg_plugin "plugins/file.h"
#if foo_OS!=2
#include <pthread.h>
#endif
#include "../Foo.h"
using namespace foo_library;
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_main(PyObject *self, PyObject *args) {
PyObject *resultobj;
int arg1 ;
char **arg2 = (char **) 0 ;
int result;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"iO:main",&arg1,&obj1)) goto
fail;
if ((SWIG_ConvertPtr(obj1,(void **) &arg2,
SWIGTYPE_p_p_char,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
result = (int)main(arg1,arg2);
There are several errors, one of which is made clear by the error
message. Where is main() declared?
Second, main already returns int(). Per ISO/IEC 14882:2003 main ALWAYS
returns int.
Third, you are calling main(). Per ISO/IEC 14882:2003 you are not
allowed to call main.
>
resultobj = PyInt_FromLong((long)result);
return resultobj;
fail:
return NULL;
}
================================================== =====
Any clues as to what is happening here or what to do next? If you
know, your help would greatly help. Thanks in advance! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jon Moldover |
last post by:
Hi, I'm using Python in my win32 app by linking to the python23.dll.
I'm trying to expose some c++ code in my app to Python so I can make
application calls from Python scripts (according to the...
|
by: Andrew Collier |
last post by:
hello,
i am not sure whether this problem relates to swig, python or my c++ compiler.
+please forgive me if this is inappropriately posted but i am sure that someone
+on this list must have some...
|
by: Helmut Zeisel |
last post by:
I want to build a static extension of Python using SWIG and VC++ 6.0 as
described in http://www.swig.org/Doc1.3/Python.html#n8 for gcc.
My file is testerl.i:
=========================
%module...
|
by: It's me |
last post by:
I am playing around with SWING building a Python module using the no brainer
example in http://www.swig.org/tutorial.html. With that first example,
/* File : example.c */
#include <time.h>...
|
by: Java and Swing |
last post by:
I am trying to wrap some C code I have. Currently I have something
like...
defs.h
-----------
typedef unsigned long MY_DIGIT;
myapp.c
-------------
void MakeDigits(MY_DIGIT digits) {
|
by: ajikoe |
last post by:
Hi,
I tried to follow the example in swig homepage.
I found error which I don't understand.
I use bcc32, I already include directory where my python.h exist in
bcc32.cfg.
/* File : example.c...
|
by: Bart Ogryczak |
last post by:
Hi,
I´m looking for some benchmarks comparing SWIG generated modules with
modules made directly with C/Python API. Just how much overhead does
SWIG give? Doing profile of my code I see, that it...
|
by: cody314 |
last post by:
Versions:
Python 2.5.1 (r251:54863, May 14 2007, 10:50:04)
SWIG Version 1.3.20
Hello I have some code that wraps a C++ library so I may use it in
python. The code basically just gets some data...
|
by: Uberman |
last post by:
I have a bit of a odd arrangement here with SWIG, Python, Embedded Python and
C++ classes exported into Python. Here's the plot:
I have a class defined in a C++ DLL library. I am wrapping this...
|
by: Basha J P M |
last post by:
I am beginner in python.
I am working through the tutorial examples from http://www.swig.org/ and
have run into some problems. I took the following command instructions from
the tutorial on...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: 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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| | |