Linking...
pytonExt_wrap.obj : error LNK2005: "int __cdecl cppFunct(int)" (?cppFunct@@YAHH@Z) already defined in pythonExt.obj
pytonExt_wrap.obj : warning LNK4006: "int __cdecl cppFunct(int)" (?cppFunct@@YAHH@Z) already defined in pythonExt.obj; second definition ignored
Creating library Debug/_pythonExt.lib and object Debug/_pythonExt.exp
Debug/_pythonExt.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
_pythonExt.dll - 2 error(s), 1 warning(s)
I do not understand at all why this is happening, any ideas?
Extending python with SWIG
I've been attempting to use SWIG with VC++ 6 in windows X to interface with python.
I created a simple c++ source file and an interface file, and sucessfully ran swig on the interface file. I then created a simple DLL project in VC++ 6, included the source and wrapper files and set up neccessary directories and options. Now, I get 2 errors and a warning when I compile it. Here they are:
I've been using SWIG to provide a C# interface.
You say you added both the source and the wrapper files. You should compile your source into a lib and compile the wrapper seperately into a lib. The wrapper will eventually call your original code, but it's just a layer on top and must be compiled seperately.
hth,
CipherCraft
You say you added both the source and the wrapper files. You should compile your source into a lib and compile the wrapper seperately into a lib. The wrapper will eventually call your original code, but it's just a layer on top and must be compiled seperately.
hth,
CipherCraft
Does that mean I create a dll file for both the wrapper and source? Is a DLL the same as a libraray?
Sorry, I'm fairly new to the c programming languages.
Sorry, I'm fairly new to the c programming languages.
Have you taken a look at Pyrex yet?
I'm sharing this in case you're doing some exploring to find alternative ways to create Python extensions. I've used SWIG too, and Pyrex seems a lot nicer to work with.
I'm sharing this in case you're doing some exploring to find alternative ways to create Python extensions. I've used SWIG too, and Pyrex seems a lot nicer to work with.
Yes, as a matter of fact, this is what my .i file looks like.
%module pyext
%{
#include "pyext.cpp"
%}
%include "pyext.cpp"
%module pyext
%{
#include "pyext.cpp"
%}
%include "pyext.cpp"
Well, that's your problem.
The function will be compiled twice.
Once in the compilation of pyext.cpp
and another time in the compilation of pyext_wrap.cxx (because the content of the pyext.cpp is included in it).
You should have an header file for the functions pyext.cpp and include it in your interface file instead.
The function will be compiled twice.
Once in the compilation of pyext.cpp
and another time in the compilation of pyext_wrap.cxx (because the content of the pyext.cpp is included in it).
You should have an header file for the functions pyext.cpp and include it in your interface file instead.
Quote:Original post by Gorg
Well, that's your problem.
The function will be compiled twice.
Once in the compilation of pyext.cpp
and another time in the compilation of pyext_wrap.cxx (because the content of the pyext.cpp is included in it).
You should have an header file for the functions pyext.cpp and include it in your interface file instead.
So, do I just change the etension of my source file to a .h file? Then go about the process as normal? And is this how my interface file should be set up?
%module pythonExt
%{
#include "pythonext.hpp"
%}
extern int cppFunct(int x);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement