Menu

#1231 libiconv can't be linked with executables

OTHER
closed
nobody
mingwPORT (5)
works-for-me
Known_bugs
2013-01-21
2009-01-11
No

Hello!

i've tried to build executable with using of
libiconv-1.11-mingwPORT-20070423-1.tar.bz2

and I got following:
C:/MinGW/lib/libiconv.a(iconv.o):iconv.c:(.text+0xe8606): undefined reference to `__errno'
C:/MinGW/lib/libiconv.a(iconv.o):iconv.c:(.text+0xe863a): undefined reference to `__errno'
C:/MinGW/lib/libiconv.a(iconv.o):iconv.c:(.text+0xe8714): undefined reference to `__errno'
C:/MinGW/lib/libiconv.a(iconv.o):iconv.c:(.text+0xe8764): undefined reference to `__errno'
C:/MinGW/lib/libiconv.a(iconv.o):iconv.c:(.text+0xe8782): undefined reference to `__errno'
C:/MinGW/lib/libiconv.a(iconv.o):iconv.c:(.text+0xe8910): more undefined references to `__errno' follow
collect2: ld returned 1 exit status

source was:
#include <iconv.h>
int main(void) { iconv_open(0,0); return 0; }

command line was:
gcc -O2 ic_test.c -o ic_test.exe -liconv 2>ic_err

Discussion

  • Keith Marshall

    Keith Marshall - 2009-01-12
    • milestone: --> Unreproducible
    • status: open --> pending-invalid
     
  • Keith Marshall

    Keith Marshall - 2009-01-12

    Works fine for me.

    How did you build the mingwPORT?
    Did that build complete successfully?
    Can you build a simple, self-contained application using `errno'?

    <example>
    #include <stdio.h>
    #include <errno.h>

    int main()
    {
    FILE *input;
    if( (input = fopen( "nonsuch", "r" )) == NULL )
    {
    perror( "fopen" );
    fprintf( stderr, "errno = %d\n", errno );
    }
    return 0;
    }
    </example>

     
  • Anonymous

    Anonymous - 2009-01-12

    I'm using binaries from sf.net download page!
    WIth using of MinGW i'm able to build executable of biew project:
    https://sourceforge.net/project/showfiles.php?group_id=1475&package_id=1454&release_id=653021
    but without libiconv support.

     
  • Anonymous

    Anonymous - 2009-01-12
    • status: pending-invalid --> open-invalid
     
  • Keith Marshall

    Keith Marshall - 2009-01-12
    • status: open-invalid --> closed-works-for-me
     
  • Keith Marshall

    Keith Marshall - 2009-01-12

    You said you were using libiconv-1.11-mingwPORT, which is *not* a binary -- you have to build it! If you didn't build it, then where did your iconv.h, and your libiconv.a come from?

    FTR, the unresolved `__errno' symbol is defined in libmsvcrt.a, (which you do *not* need to, and indeed *shouldn't*, specify explicitly on your command line), as a reference to a standard DLL symbol; that should be available to *all* MinGW applications, so your problem may not be specifically related to libiconv.a usage. That is where I am going, when I ask you to run a specific self-contained test sample. Whatever else you can, or can't build is irrelevant. If you don't give full answers to my questions, then I'm sorry, but I can't help you further.

    AFAICT, there is no reportable bug here. You may have a faulty MinGW installation, and should seek assistance on the mailing list.

     
  • Anonymous

    Anonymous - 2009-01-12

    libmsvcrt.a defines _errno symbol with single '_' leading character only? but not __errno!

     
  • Keith Marshall

    Keith Marshall - 2009-01-12

    Real info, copied and pasted from my own Win2K system:

    $ nm --print-file /mingw/lib/libiconv.a | grep errno
    d:/usr/mingw-3.4.5/lib/libiconv.a:iconv.o: U __errno

    $ nm --print-file /mingw/lib/libmsvcrt.a | grep errno
    d:/usr/mingw-3.4.5/lib/libmsvcrt.a:dayhs00152.o:00000000 T __errno
    d:/usr/mingw-3.4.5/lib/libmsvcrt.a:dayhs00152.o:00000000 I __imp___errno
    d:/usr/mingw-3.4.5/lib/libmsvcrt.a:dayhs00037.o:00000000 T ___doserrno
    d:/usr/mingw-3.4.5/lib/libmsvcrt.a:dayhs00037.o:00000000 I __imp____doserrno

    Note that the symbol is `__errno' in *both* cases; (GCC adds an extra leading underscore to the symbol name stored in the object file, when that is PE-COFF format). This symbol is unresolved in libiconv.a; defined in libmsvcrt.a

    If yours isn't like this, then it isn't correctly installed.

    You still haven't bothered to answer the questions I posed! See:
    http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

    for why I have no further help to offer you.

     
  • Kelley567

    Kelley567 - 2009-01-25

    Please try libiconv-1.12 mingwPORT if good.
    https://sourceforge.net/tracker2/?func=detail&aid=2531139&group_id=2435&atid=752210

    source:
    #include <windows.h>
    #include <stdio.h>
    #include <errno.h>
    #include <iconv.h>

    int main(void) {
    iconv_t i;
    const char c1[]="dummy";
    const char c2[]="utf-8";

    i = iconv_open(c1, c2);
    printf("iconv_t = %d\n", i);
    printf("errno = %d\n", errno);
    return EXIT_SUCCESS;
    }

    Test environment:
    gcc version 3.4.5(mingw-vista special r3)
    GNU ld version 2.17.50 20060824
    GNU ld(GNU Binutils) 2.19

    #This English used the translation site.
    #There may be funny expression.

     
  • Earnie Boyd

    Earnie Boyd - 2013-01-21
    • labels: MinGW --> mingwPORT
    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> Known_bugs
    • milestone: Unreproducible --> OTHER
     
MongoDB Logo MongoDB