G
Gerhard Haering
Hello,
I used to build Python extension modules with mingw. Now, Python has
switched to the MSVCR71 runtime with version 2.4, and I thought mingw
has support for this. But I get problems with symbols being referenced
from the wrong DLLs.
You can see the problem by compiling this:
##################
#include <string.h>
int main()
{
char* s;
int i;
for (i = 0; i < 10; i++) {
s = strdup("foo");
free(s);
}
return 0;
}
##################
with gcc x.c -lmsvcr71
Then if you run a.exe it crashes.
If you use depends.exe on it, you see that it resolves strdup() via
msvcrt, but the rest with msvcr71.dll. That's why strdup() is using
the one malloc, but free() a different free() from the other DLL,
which is undoubtedly the reason for the crash.
Is there any way I can force mingw to not link in msvcr for things
like strdup?
I think I found a very strange and ugly workaround: if I use _strdup()
instead of strdup(), it is resolved using the msvcr71 DLL.
I hope it is (soon) possible to use only the msvcr71 runtime from the
mingw compiler.
-- Gerhard
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFByCmWdIO4ozGCH14RAu0nAJwKYhMLulwl52UltcFk00sy55yEpQCfaTsS
Ba8Q5W8g23lRe/VM/K/kBCU=
=L8+w
-----END PGP SIGNATURE-----
I used to build Python extension modules with mingw. Now, Python has
switched to the MSVCR71 runtime with version 2.4, and I thought mingw
has support for this. But I get problems with symbols being referenced
from the wrong DLLs.
You can see the problem by compiling this:
##################
#include <string.h>
int main()
{
char* s;
int i;
for (i = 0; i < 10; i++) {
s = strdup("foo");
free(s);
}
return 0;
}
##################
with gcc x.c -lmsvcr71
Then if you run a.exe it crashes.
If you use depends.exe on it, you see that it resolves strdup() via
msvcrt, but the rest with msvcr71.dll. That's why strdup() is using
the one malloc, but free() a different free() from the other DLL,
which is undoubtedly the reason for the crash.
Is there any way I can force mingw to not link in msvcr for things
like strdup?
I think I found a very strange and ugly workaround: if I use _strdup()
instead of strdup(), it is resolved using the msvcr71 DLL.
I hope it is (soon) possible to use only the msvcr71 runtime from the
mingw compiler.
-- Gerhard
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFByCmWdIO4ozGCH14RAu0nAJwKYhMLulwl52UltcFk00sy55yEpQCfaTsS
Ba8Q5W8g23lRe/VM/K/kBCU=
=L8+w
-----END PGP SIGNATURE-----