Subject: | Library include order for gcc |
Hello,
I am testing building modules from CPAN using Strawberry Perl and I wanted to find out whether it breaks
if I install MinGW separately.
Since MinGW does not modify PATH variable during installation, the gcc, as, ld executables are really
from Strawberry, but I found out that some libraries are picked up from MinGW's folder.
Example:
Building Text::Iconv v1.7.
Strawberry Perl 5.10.1 installed to C:\strawberry.
MinGW with gcc 4.5.2 installed in C:\MinGW.
Writing Makefile for this module fails, because it picks up crt2.o from C:\MinGW\lib and not from
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../ (== C:\strawberry\lib).
I tried to build the C source file (iconvtest.c) from module's Makefile.PL:
#include <iconv.h>
int main(void)
{
(void) iconv_open("", "");
}
using their compilation command:
gcc -v -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -
DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVCRT_READFIX -s -L"C:\strawberry\perl\lib\CORE" -
L"C:\strawberry\c\lib" -liconv -o iconvtest iconvtest.c -liconv
The compilation fails.
The problem is that collect2.exe looks for crt2.o in gcc search paths, which for the gcc supplied with
Strawberry Perl 5.10.1 is:
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/;
C:/strawberry/c/bin/../lib/gcc/;
/mingw/lib/gcc/mingw32/3.4.5/;
/usr/lib/gcc/mingw32/3.4.5/;
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/mingw32/3.4.5/;
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/lib/;
/mingw/lib/gcc/mingw32/../../../mingw32/lib/mingw32/3.4.5/;
/mingw/lib/gcc/mingw32/../../../mingw32/lib/;
/mingw/lib/mingw32/3.4.5/;
/mingw/lib/;
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../mingw32/3.4.5/;
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../;
/mingw/lib/gcc/mingw32/../../mingw32/3.4.5/;/mingw/lib/gcc/mingw32/../../;
/lib/mingw32/3.4.5/;
/lib/;
/usr/lib/mingw32/3.4.5/;
/usr/lib/
(It is slightly different if C:\MinGW does not exist, though).
Since crt2.o resides in C:\strawberry\lib, but also in C:\MinGW\lib, in this particular case, the problem
is that /mingw/lib is listed before C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../
The compilation works OK if LIBRARY_PATH is set to C:\strawberry\lib.
I think that Strawberry Perl's library paths should be all before /mingw/... paths, but maybe there is a
reason, why this particular order of search path was chosen. Could you please clarify?
Thank you.