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

Robin Becker robin at reportlab.com
Tue Aug 21 08:59:34 EDT 2018


On 17/08/2018 18:32, Tim Roberts wrote:
.........

> 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?
> 
it's an experiment to see if the ageing libart_lgpl code which reportlab uses can be replaced with something based on antigrain so 
not yet public. However, I see a similar error in aggdraw (se eg https://github.com/pytroll/aggdraw).

> 
>> 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.
> 

I don't have a .def file; the compilation is being handled purely by python setup.py build_ext which might be creating a temporary 
one somehow, but I cannot find it. Needless to say this is happening only on windows. I have these in temp

C:\code\hg-repos\taggstate\REPOS\aggstate>ls build\temp.win-amd64-2.7\Release
_aggstate.exp           _aggstate.obj           agg25
_aggstate.lib           _aggstate.pyd.manifest

digging a bit deeper I find taht the problem comes from the exp file and the linker /EXPORT. It seems that the 
/EXPORT:init_aggstate can be suppressed for this build and the warning disappears, but something (I assume the exp) supplies the 
export. Certainly the pyd appears to work.
-- 
Robin Becker


More information about the python-win32 mailing list