Problem Einbindung regex.h und ld



  • Hi,
    ich möchte die Funktionen der regex.h unter Windows verwenden. Dafür gibt es ja ein extra Paket (http://people.delphiforums.com/gjc/gnu_regex.html).
    Nun, bei der Einbindung in mein Programm bekomme ich permanent Linker-Fehler:

    ccE7aaaa.o:main.c: (.text+0x57): undefined reference to regcomp' ccE7aaaa.o:main.c: (.text+0x92): undefined reference toregexec'
    ccE7aaaa.o:main.c: (.text+0xc8): undefined reference to regfree' ccE7aaaa.o:main.c: (.text+0xdc): undefined reference toregfree'
    collect2: ld returned 1 exit status

    Mein programm:

    #include <sys/types.h> 
    #include <stdio.h> 
    #include "regex.h"
    
    int main(int argc,char *argv[]) 
    { 
    regex_t rx; 
    regmatch_t match; 
    if (argc<3) return 1; 
    if (regcomp(&rx,argv[1],REG_EXTENDED|REG_ICASE)) return 2; 
    if (!regexec(&rx,argv[2],1,&match,0)) {
     printf("%.*s\n",match.rm_eo-match.rm_so,argv[2]+match.rm_so);
     regfree(&rx); return 0; 
    } 
    
    regfree(&rx); 
    return 3; 
    }
    

    Wenn ich jetzt bei der include-Anweisung anstelle von regex.h regex.c (oder beide zusammen wähle erhalte ich folgende Fehler:

    ccSubaaa.o:main.c: (.text+0x21): undefined reference to bzero' ccSubaaa.o:main.c: (.text+0x10ab): undefined reference tobzero'
    ccSubaaa.o:main.c: (.text+0x3f27): undefined reference to bzero' ccSubaaa.o:main.c: (.text+0x42eb): undefined reference tobcopy'
    ccSubaaa.o:main.c: (.text+0x5a63): undefined reference to bcopy' ccSubaaa.o:main.c: (.text+0x5dd5): undefined reference tobcmp'
    ccSubaaa.o:main.c: (.text+0x5fac): undefined reference to bcopy' ccSubaaa.o:main.c: (.text+0x61e6): undefined reference tobcopy'
    ccSubaaa.o:main.c: (.text+0x66a9): undefined reference to bcopy' ccSubaaa.o:main.c: (.text+0x6865): undefined reference tobcopy'
    collect2: ld returned 1 exit status

    Ich verstehe das Problem nicht recht.
    Kann mir jemand helfen? Vielen Dank,
    Grüße,
    Simon

    P.S.: WinXP Pro, MinGW-5.1.3, GCC Version 3.4.5 (mingw special)


Anmelden zum Antworten