473,406 Members | 2,369 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,406 software developers and data experts.

ImportError: dynamic module does not define init function(initmymodule)

I have an c++ header file.

//some_class.h

#ifndef _SOME_CLASS_H_
#define _SOME_CLASS_H_

class SomeClass
{
public:
int sqr(int a);
};
#endif //_SOME_CLASS_H_

and I have an definition file some_class.C

//some_class.C

#include "some_class.h"
int SomeClass::sqr(int a){
return a*a;
}
And I have an interface file
%module mytest
%{
#include "some_class.h"
}
%include "some_class.h"

My question is when I try to import mytest in python it does import it
but I'm not able to access the SomeClass..

Can anyone help..

Balaji

When I try to conver this into python module by using SWIG I manage to
import
Jul 18 '05 #1
1 3548
ba****@email.arizona.edu (Balaji) writes:
I have an c++ header file.

//some_class.h

#ifndef _SOME_CLASS_H_
#define _SOME_CLASS_H_

class SomeClass
{
public:
int sqr(int a);
};
#endif //_SOME_CLASS_H_

and I have an definition file some_class.C

//some_class.C

#include "some_class.h"
int SomeClass::sqr(int a){
return a*a;
}
And I have an interface file
%module mytest
%{
#include "some_class.h"
}
%include "some_class.h"

My question is when I try to import mytest in python it does import it
but I'm not able to access the SomeClass..


Does SWIG expect to be compiled using a C++ compiler (I don't know).
I suspect you're falling victim to C++ name mangling, but I don't know
enough about SWIG to tell you what to try instead.

Cheers,
mwh

--
Programming languages should be designed not by piling feature on
top of feature, but by removing the weaknesses and restrictions
that make the additional features appear necessary.
-- Revised(5) Report on the Algorithmic Language Scheme
Jul 18 '05 #2

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

Similar topics

0
by: mg | last post by:
Hi everybody... I am using Python API in order to create bindings. So, in the init function of my module, I create constants : PyMODINIT_FUNC initMyModule( void ) { PyObject* module =...
1
by: mg | last post by:
Hi everybody... I am using Python API in order to create bindings. So, in the init function of my module, I create constants : PyMODINIT_FUNC initMyModule( void ) { PyObject* module =...
1
by: Torsten Mohr | last post by:
Hi, i write an extension module in C at the moment. I want to define some constants (integer mainly, but maybe also some strings). How do i do that best within this extension module in C? ...
6
by: mg | last post by:
Hello, I am writting bindings for a FEM application. In one of my function 'initModulename', called when the module is imported, I would like to get the argc and argv arguments used in the main...
3
by: kman3048 | last post by:
Hello, as a relative newcomer to Python API programming I've got a problem: To extend Python: - there is an API C call to create a module - there is also a API C call to create a method -...
2
by: Andras Balogh | last post by:
I have a dll that contains all kinds of services (input, audio, video, etc..), and I would like to export these to Python as separate modules. Now, if I call Py_InitModule with a name that's...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
Oralloy
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,...
0
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...
0
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...
0
agi2029
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 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.