#24 ld did not resolve library path properly

closed
None
2
2014-07-17
2003-03-06
No

My configure script with the command
AC_CHECK_LIB(AnaCommon,main)
fails. A look in config.log says the ld cannot find
-lAnaCommon. But I installed this library in the path
/usr/local/lib.
ls -la /usr/local/lib show the following result
total 22527
drwxr-xr-x 2 TWe A.. 4096 Mar 5 14:52 .
drwxr-xr-x 5 TWe A.. 0 Mar 5 10:08 ..
-rw-r--r-- 1 TWe A.. 45018306 Mar 5 14:52
libAnaCommon.a
-rw-r--r-- 1 TWe A.. 1109972 Mar 5 14:51
libAnaCommon.dll.a
-rw-r--r-- 1 TWe A.. 716 Mar 5 14:51 libAnaCommon.la

ld -lAnaCommon --verbose
results int the following:

GNU ld version 2.13
Supported emulations:
i386pe
using internal linker script:
==================================================
/* Default linker script, for normal executables */
OUTPUT_FORMAT(pei-i386)
SEARCH_DIR("/mingw/mingw32/lib");
SEARCH_DIR("/mingw/lib"); SEARCH_DIR("/usr/local/lib");
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
ENTRY(_mainCRTStartup)
SECTIONS
{
.text __image_base__ + __section_alignment__ :
{
*(.init)
*(.text)
*(SORT(.text$*))
*(.glue_7t)
*(.glue_7)
___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
LONG (-1); *(SORT(.ctors.*)); *(.ctors); *(.ctor);
LONG (0);
___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
LONG (-1); *(SORT(.dtors.*)); *(.dtors); *(.dtor);
LONG (0);
*(.fini)
/* ??? Why is .gcc_exc here? */
*(.gcc_exc)
etext = .;
*(.gcc_except_table)
}
/* The Cygwin32 library uses a section to avoid
copying certain data
on fork. This used to be named ".data". The
linker used
to include this between __data_start__ and
__data_end__, but that
breaks building the cygwin32 dll. Instead, we
name the section
".data_cygwin_nocopy" and explictly include it
after __data_end__. */
.data BLOCK(__section_alignment__) :
{
__data_start__ = . ;
*(.data)
*(.data2)
*(SORT(.data$*))
__data_end__ = . ;
*(.data_cygwin_nocopy)
}
.rdata BLOCK(__section_alignment__) :
{
*(.rdata)
*(SORT(.rdata$*))
*(.eh_frame)
}
.pdata BLOCK(__section_alignment__) :
{
*(.pdata)
}
.bss BLOCK(__section_alignment__) :
{
__bss_start__ = . ;
*(.bss)
*(COMMON)
__bss_end__ = . ;
}
.edata BLOCK(__section_alignment__) :
{
*(.edata)
}
/DISCARD/ :
{
*(.debug$S)
*(.debug$T)
*(.debug$F)
*(.drectve)
}
.idata BLOCK(__section_alignment__) :
{
/* This cannot currently be handled with grouped
sections.
See pe.em:sort_sections. */
SORT(*)(.idata$2)
SORT(*)(.idata$3)
/* These zeroes mark the end of the import list. */
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
SORT(*)(.idata$4)
SORT(*)(.idata$5)
SORT(*)(.idata$6)
SORT(*)(.idata$7)
}
.CRT BLOCK(__section_alignment__) :
{
*(SORT(.CRT$*))
}
.endjunk BLOCK(__section_alignment__) :
{
/* end is deprecated, don't use it */
end = .;
_end = .;
__end__ = .;
}
.rsrc BLOCK(__section_alignment__) :
{
*(.rsrc)
*(SORT(.rsrc$*))
}
.reloc BLOCK(__section_alignment__) :
{
*(.reloc)
}
.stab BLOCK(__section_alignment__) (NOLOAD) :
{
[ .stab ]
}
.stabstr BLOCK(__section_alignment__) (NOLOAD) :
{
[ .stabstr ]
}
}

==================================================
attempt to open /mingw/mingw32/lib/libAnaCommon.dll.a
failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.dll failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll failed
attempt to open /mingw/mingw32/lib\libAnaCommon.a failed
attempt to open /mingw/lib/libAnaCommon.dll.a failed
attempt to open /mingw/lib/AnaCommon.dll.a failed
attempt to open /mingw/lib/libAnaCommon.a failed
attempt to open /mingw/lib/libAnaCommon.dll failed
attempt to open /mingw/lib/AnaCommon.dll failed
attempt to open /mingw/lib\libAnaCommon.a failed
attempt to open /usr/local/lib/libAnaCommon.dll.a failed
attempt to open /usr/local/lib/AnaCommon.dll.a failed
attempt to open /usr/local/lib/libAnaCommon.a failed
attempt to open /usr/local/lib/libAnaCommon.dll failed
attempt to open /usr/local/lib/AnaCommon.dll failed
attempt to open /usr/local/lib\libAnaCommon.a failed
attempt to open /lib/libAnaCommon.dll.a failed
attempt to open /lib/AnaCommon.dll.a failed
attempt to open /lib/libAnaCommon.a failed
attempt to open /lib/libAnaCommon.dll failed
attempt to open /lib/AnaCommon.dll failed
attempt to open /lib\libAnaCommon.a failed
attempt to open /usr/lib/libAnaCommon.dll.a failed
attempt to open /usr/lib/AnaCommon.dll.a failed
attempt to open /usr/lib/libAnaCommon.a failed
attempt to open /usr/lib/libAnaCommon.dll failed
attempt to open /usr/lib/AnaCommon.dll failed
attempt to open /usr/lib\libAnaCommon.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.dll.a
failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.dll failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll failed
attempt to open /mingw/mingw32/lib\AnaCommon.lib failed
attempt to open /mingw/lib/libAnaCommon.dll.a failed
attempt to open /mingw/lib/AnaCommon.dll.a failed
attempt to open /mingw/lib/libAnaCommon.a failed
attempt to open /mingw/lib/libAnaCommon.dll failed
attempt to open /mingw/lib/AnaCommon.dll failed
attempt to open /mingw/lib\AnaCommon.lib failed
attempt to open /usr/local/lib/libAnaCommon.dll.a failed
attempt to open /usr/local/lib/AnaCommon.dll.a failed
attempt to open /usr/local/lib/libAnaCommon.a failed
attempt to open /usr/local/lib/libAnaCommon.dll failed
attempt to open /usr/local/lib/AnaCommon.dll failed
attempt to open /usr/local/lib\AnaCommon.lib failed
attempt to open /lib/libAnaCommon.dll.a failed
attempt to open /lib/AnaCommon.dll.a failed
attempt to open /lib/libAnaCommon.a failed
attempt to open /lib/libAnaCommon.dll failed
attempt to open /lib/AnaCommon.dll failed
attempt to open /lib\AnaCommon.lib failed
attempt to open /usr/lib/libAnaCommon.dll.a failed
attempt to open /usr/lib/AnaCommon.dll.a failed
attempt to open /usr/lib/libAnaCommon.a failed
attempt to open /usr/lib/libAnaCommon.dll failed
attempt to open /usr/lib/AnaCommon.dll failed
attempt to open /usr/lib\AnaCommon.lib failed
c:\MinGW\bin\ld.exe: cannot find -lAnaCommon

if I do
ld -L /usr/local/lib -lAnaCommon --verbose
this results in:
GNU ld version 2.13
Supported emulations:
i386pe
using internal linker script:
==================================================
.
.
.
==================================================
attempt to open
c:/Programme/msys/1.0/local/lib/libAnaCommon.dll.a
succeeded

Fine the lib was found but where was the difference. So
I did my last try move the library to where the mingw
lib are and doing
ld -lAnaCommon --verbose
results in:
GNU ld version 2.13
Supported emulations:
i386pe
using internal linker script:
==================================================
.
.
.
==================================================
attempt to open /mingw/mingw32/lib/libAnaCommon.dll.a
failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.dll failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll failed
attempt to open /mingw/mingw32/lib\libAnaCommon.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.dll.a
failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.a failed
attempt to open /mingw/mingw32/lib/libAnaCommon.dll failed
attempt to open /mingw/mingw32/lib/AnaCommon.dll failed
attempt to open /mingw/mingw32/lib\libAnaCommon.a failed
attempt to open /mingw/lib/libAnaCommon.dll.a failed
attempt to open /mingw/lib/AnaCommon.dll.a failed
attempt to open /mingw/lib/libAnaCommon.a succeeded

For me it is no difference for searching in /mingw/lib
or /usr/local/lib but ld make a difference.

Thomas Weber

Discussion

  • Earnie Boyd

    Earnie Boyd - 2003-03-06
    • labels: 103946 -->
    • assigned_to: dannysmith --> nobody
     
  • Earnie Boyd

    Earnie Boyd - 2003-03-06
    • priority: 5 --> 2
    • assigned_to: nobody --> earnie
     
  • Earnie Boyd

    Earnie Boyd - 2003-03-06

    Logged In: YES
    user_id=15438

    <b>I moved this to a support request because it's not a bug.</b>

    Remember that the MinGW ld.exe is a Windows native program
    and unless you nave %CD%\usr\local\lib as a path then ld
    isn't going to know what /usr/local/lib relates to w.r.t.
    MSYS or Cygwin. If you're using MSYS then -L /usr/local/lib
    is translated to the Windows absolute path before ld sees
    the path so that it can find the path.

    Perhaps a ../local/lib could be added to the default search
    order in the ld scripts found in /mingw/mingw32/lib/ so that
    it does what you want.

    Earnie.

     
  • Thomas Weber

    Thomas Weber - 2003-03-07

    Logged In: YES
    user_id=672321

    Sorry I forgot to translate the "linux" path in the real Windows
    path and the search in /usr/local/lib is in my case
    c:\usr\local\lib
    (mingw was installed in c:\mingw). Is there a simple trick
    to add
    an additional path for searching? There are a lot of
    package with
    the autoconf macro AC_CHECK_LIB. If the macro check for libs
    wich were normal installed with: --prefix=/usr or with
    --prefix=/usr/local in the configure command line, make and make
    install, the autoconf macro fails. Of course I will be
    possible to set
    LD_FLAGS='-L /usr/lib'. Is this the only way? If so, there
    should be
    a hint to that problem.

    Thomas Weber

     
  • Earnie Boyd

    Earnie Boyd - 2003-03-07

    Logged In: YES
    user_id=15438

    As I said, you could modify the ld scripts found in
    mingw/mingw32/lib/ldscripts/ by adding a
    ``SEARCH_DIR(c:/usr/local/lib)'' in the evident appropriate
    place. Perhaps you could even submit a patch to binutils to
    make it perminent; i.e.: so that you don't have to add them
    with each update.

    Earnie.

     
  • Earnie Boyd

    Earnie Boyd - 2004-04-25
    • status: open --> closed
     
  • Earnie Boyd

    Earnie Boyd - 2004-04-25

    Logged In: YES
    user_id=15438

    Old request - closed. If you still have a problem please
    post to mingw-users@lists.sf.net or use one of the available
    forums found on the SF project page for this project.

    Earnie

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks