[python-win32] LNK4197 error building c++ extension

Tim Roberts timr at probo.com
Fri Aug 17 13:32:59 EDT 2018


Robin Becker wrote:
> I am not a great C++ person so as I am building my first C++ extension 
> I am seeing this error which I don't understand
>
> > _aggstate.obj : warning LNK4197: export 'init_aggstate' specified 
> multiple times; using first specification
> >    Creating library build\temp.win-amd64-2.7\Release\_aggstate.lib 
> and object build\temp.win-amd64-2.7\Release\_aggstate
> > .exp

It's not an error, it's a warning.  And this has nothing to do with 
C++.  Is this your own private project, or is it one I can go look up?


> I looked in the preprecessor output(_aggstate.i) and see this single 
> occurrence of aggstate_init
>
>> #line 1191 "_aggstate.cxx"
>> extern "C" __declspec(dllexport) void init_aggstate(void)
>> {
>>          aggstate_init();
>> }
>
> is this some feature of C++ or is there a real issue here?

My guess is that you have listed "init_aggstate" in the ".def" file that 
lists the exported functions.  That's the first export specification.  
You are also using __declspec(dllexport) in the function definition, and 
that's the second export specification. When you use 
__declspec(dllexport), you don't need the ".def" file.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list