On Wed, Nov 7, 2012 at 6:33 AM, Václav Šmilauer <e...@doxos.eu> wrote:
>
>>> Just for the heck of it, I changed
>>> Python27/lib/distutils/cygwincompiler.py to return "msvcrt" instead of
>>> "msvcr90". It works.
>>>
>>> My question is: do we really need to link our modules to msvcr*, if
>>> python.dll (which we link already when building modules) links to msvcrt
>>> itself? I assume there is a reason for that, but it is not clear to me.
>>> Maybe I am misunderstanding the difference in linking on Windows? Under
>>> Linux, linking is transitive, therefore if B (python) links to A
>>> (msvcrt), then C (my module) linking to B links to A automatically.
>> See the following documents:
>> http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
>> http://msdn.microsoft.com/en-us/library/ms235460.aspx
> Thanks for the references.
>
> I double-checked python.exe/python27.dll, they link to
> c:\windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3c9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcr90.dll.
> Since this directory is not in $PATH, it does not get picked up when the
> .pyd gets loaded (I had to copy msvcr90.dll to the directory, and there
> were two copies afterwards, which explains the crash).

The only reason to not use msvcrt.dll is for newer functionality not
present in msvcrt.dll.  However, one should be careful to use one or
the other for memory and shared pointer functionality.  The
msvcr90.dll is distributed with a specific version of MSVC and is
allowed to be shared but only if the developer has licenses for that
right.  The msvcrt.dll is the common expected default library which is
what MinGW uses by default.

>
> I also tried to remove -lmsvcr* from the link command, and modules get
> compiled just fine. I know I am just trying random things, perhaps
> without proper understanding, but... why bother linking to msvcr* at
> all? Am I just lucky in this case?
>

I don't think any open source project should require a shared library
that isn't standard.  However, if there is a need then that open
source project should ensure that the crossing boundaries doesn't
happen.  Using LoadLibrary/GetProcAddress combo might help with that
so that you're using only the functions you require and not
encumbering the linker to decide.

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to