Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: libintl.a for Strawberry Perl

by fdesar (Beadle)
on Jan 24, 2019 at 14:25 UTC ( [id://1228921]=note: print w/replies, xml ) Need Help??


in reply to Re: libintl.a for Strawberry Perl
in thread libintl.a for Strawberry Perl

Great: I finally found it as you said in in MSYS2: libintl.a (and libintl.h too)

But that doesn't seem sufficient: when I compile and link a simple program calling gettext(), I get a linking error :

Program:

#include "libintl.h" int main() { gettext("abc"); }

Compiling:

C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\Moi\test>gcc -o t +est test.c C:\Users\Moi\AppData\Local\Temp\ccCWWHXa.o:test.c:(.text+0x15): undefi +ned reference to `libintl_gettext' collect2.exe: error: ld returned 1 exit status

I'm puzzled for now...

BTW, the module I want to get working is Locale::gettext which does exactly what I need under Linux and macOS.

I tried the Gido's pure Perl version of Locale::gettext_pp but his code doen't understand the windows pseudo-locale so it doesn't work.

PS: before, I hated Windows but I think now I abhor it! :-(

Replies are listed 'Best First'.
Re^3: libintl.a for Strawberry Perl
by VinsWorldcom (Prior) on Jan 24, 2019 at 21:30 UTC

    Your problem is the supplied library from Developer Files is in 32-bit format and your using 64-bit Strawberry Perl; and thus, 64-bit gcc. Your test program above compiles fine for me with Strawberry 5.18 32-bit:

    gcc .\test.c -I.\include -L.\lib -lintl -o test.exe

    Try a 32-bit Perl (and thus 32-bit gcc) or try the following.

    Using your existing 64-bit Strawberry (and thus 64-bit gcc), from a cmd.exe prompt in the directory where you unzip both the Developer files (from above) link and the Binaries

    pexports .\bin\libintl3.dll > intl.def dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libintl.a --inp +ut-def intl.def gcc .\test.c -I .\include -L . -lintl -o test.exe

    The above worked for me - creating my own 64-bit libintl.a from the provided libintl3.dll and then compiling test.exe linking that created libintl.a

      I confirm: it works for me too: many, many thanks!
      Sounds logical, thanks. I’ll try that asap. Curiously, the libintl. a I copied was from MSY2 mingwing 64 (and it neither works on it!). So they it seems they do have a bug in their 64bit distribution too...

      Many thanks!

      OK, now I can compile Locale::gettext correctly. But unfortunatly, the gettext.xs.dll it builds up won't load.

      I used the Strawberry portable Perl 64 with the standard build method (as cpan fails) by downloading the module and doing perl Makefile.PL; gmake to generate it. And it fails on gmake test.

      If I ldd gettext.xs.dll, I find it has some unknown unresolved references:

      ldd.exe gettext.xs.dll ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffb4d030000) KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffb4ac300 +00) KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffb49 +e50000) ??? => ??? (0x67a00000) ??? => ??? (0x7ffb4a490000)

      but "???" doesn't really help to identify the problem. I suspect it still has something to do with 32bit vs 64bit but don't really know what to do next. Searching... :-)

      I think the two unknown references should have been:

      apphelp.dll => /c/Windows/SYSTEM32/apphelp.dll (0x7ffb47210000) msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ffb4a490000)

      Here is the log of gmake in case it could help:

      "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\bin\perl.ex +e" -MExtUtils::Command::MM -e cp_nonempty -- gettext.bs blib\arch\aut +o\Locale\gettext\gettext.bs 644^M "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\bin\perl.ex +e" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\lib\Ext +Utils/xsubpp" -typemap C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-p +ortable\perl\lib\ExtUtils\typemap gettext.xs > gettext.xsc^M Please specify prototyping behavior for gettext.xs (see perlxs manual) +^M "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\bin\perl.ex +e" -MExtUtils::Command -e mv -- gettext.xsc gettext.c^M gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDI +O -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS + -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2 -D +VERSION=\"1.07\" -DXS_VERSION=\"1.07\" "-IC:\Users\Moi\strawberry-pe +rl-5.28.1.1-64bit-portable\perl\lib\CORE" gettext.c^M "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\bin\perl.ex +e" -MExtUtils::Mksymlists \^M -e "Mksymlists('NAME'=>\"Locale::gettext\", 'DLBASE' => 'gettext' +, 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' +=> []);"^M g++.exe gettext.def -o blib\arch\auto\Locale\gettext\gettext.xs.dll -m +dll -s -L"C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\l +ib\CORE" -L"C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\li +b" gettext.o "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\ +perl\lib\CORE\libperl528.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64 +bit-portable\c\lib\libintl.a" "C:\Users\Moi\strawberry-perl-5.28.1.1- +64bit-portable\c\x86_64-w64-mingw32\lib\libmoldname.a" "C:\Users\Moi\ +strawberry-perl-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\libk +ernel32.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\x8 +6_64-w64-mingw32\lib\libuser32.a" "C:\Users\Moi\strawberry-perl-5.28. +1.1-64bit-portable\c\x86_64-w64-mingw32\lib\libgdi32.a" "C:\Users\Moi +\strawberry-perl-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\lib +winspool.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\x +86_64-w64-mingw32\lib\libcomdlg32.a" "C:\Users\Moi\strawberry-perl-5. +28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\libadvapi32.a" "C:\Use +rs\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\l +ib\libshell32.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portabl +e\c\x86_64-w64-mingw32\lib\libole32.a" "C:\Users\Moi\strawberry-perl- +5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\liboleaut32.a" "C:\U +sers\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32 +\lib\libnetapi32.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-port +able\c\x86_64-w64-mingw32\lib\libuuid.a" "C:\Users\Moi\strawberry-per +l-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\libws2_32.a" "C:\U +sers\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32 +\lib\libmpr.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\ +c\x86_64-w64-mingw32\lib\libwinmm.a" "C:\Users\Moi\strawberry-perl-5. +28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\libversion.a" "C:\User +s\Moi\strawberry-perl-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\li +b\libodbc32.a" "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\ +c\x86_64-w64-mingw32\lib\libodbccp32.a" "C:\Users\Moi\strawberry-perl +-5.28.1.1-64bit-portable\c\x86_64-w64-mingw32\lib\libcomctl32.a" -Wl, +--enable-auto-image-base^M "C:\Users\Moi\strawberry-perl-5.28.1.1-64bit-portable\perl\bin\perl.ex +e" -MExtUtils::Command -e chmod -- 755 blib\arch\auto\Locale\gettext\ +gettext.xs.dll^
        If I ldd gettext.xs.dll, I find it has some unknown unresolved references

        I don't understand the ldd output, but yours looks pretty normal compared to other 64-bit strawberry xs.dlls that are not troublesome. For example, for lib/auto/Win32/Win32.xs.dll, I'm seeing:
        $ ldd.exe lib/auto/Win32/Win32.xs.dll ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x76db0000) kernel32.dll => /c/Windows/system32/kernel32.dll (0x76c90000) KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefc9 +d0000) ??? => ??? (0x64cc0000)
        What's the error message you're seeing when gettext.xs.dll fails to load ? (It's likely not very helpful ... but worth a try.)
        Are there any pop-ups associated with the failure ? If so, what message so they provide ?

        When I want to build an import library from a dll, I start with gendef.exe (which ships with strawberry) and use it to create a def file:
        gendef -a mydll.dll then, using the generated mydll.def: dlltool --kill-at --input-def mydll.def --output-lib libmydll.a
        I don't know if that is what you need, or if it will provide better mileage than VinsWorldcom's method using pexports.

        If you're using MSYS2 dlls, you'll want the ones that are in the mingw64\bin - and then you might as well just use the associated import lib (.dll.a) in the mingw64\lib folder.
        The mingw64\lib folder also probably provides static (.a) libs if you want to avoid the dll dependency.

        Cheers,
        Rob

        My impression is that both perl and XS module should be compiled with the same compiler (useful discussion here: How to make an XS module with a different C compiler?). Ot at least it removes an uncertainty with your troubleshooting.

        To see what compiler my perl is compiled with I do: perl -MConfig -e 'print $Config{cc}' (likewise print the Config hash to see cppflags and ldflags).

        bw, bliako

Re^3: libintl.a for Strawberry Perl
by bliako (Monsignor) on Jan 24, 2019 at 16:10 UTC

    Try gcc -o test test.c -lintl assuming libintl.* is in the libraries search path, alternatively tell gcc where to find it using -L blahblahlocation

      I even tried:

      gcc -o test -lintl -I. test.c

      with the same result.

      But when I try to link with the libintl.a itself, I get a very different result:

      gcc -o test test.c libintl.a libintl.a(dcigettext.o):(.text+0x4bf): undefined reference to `__errno +' libintl.a(dcigettext.o):(.text+0xb7d): undefined reference to `__errno +' libintl.a(dcigettext.o):(.text+0xcf6): undefined reference to `__errno +' libintl.a(dcigettext.o):(.text+0xd25): undefined reference to `__errno +' libintl.a(dcigettext.o):(.text+0xdc9): undefined reference to `stpcpy' libintl.a(dcigettext.o):(.text+0xede): undefined reference to `__errno +' libintl.a(dcigettext.o):(.text+0x10b1): undefined reference to `__errn +o' libintl.a(dcigettext.o):(.text+0x113a): undefined reference to `__errn +o' libintl.a(dcigettext.o):(.text+0x1149): undefined reference to `getuid +' libintl.a(dcigettext.o):(.text+0x1150): undefined reference to `geteui +d' libintl.a(dcigettext.o):(.text+0x1315): undefined reference to `getgid +' libintl.a(dcigettext.o):(.text+0x131c): undefined reference to `getegi +d' libintl.a(localcharset.o):(.text+0xb): undefined reference to `nl_lang +info' libintl.a(localename.o):(.text+0x7): undefined reference to `uselocale +' libintl.a(localename.o):(.text+0x27): undefined reference to `uselocal +e' libintl.a(localename.o):(.text+0xca): undefined reference to `uselocal +e' libintl.a(setlocale.o):(.text+0x36b): undefined reference to `newlocal +e' libintl.a(setlocale.o):(.text+0x39b): undefined reference to `__errno' libintl.a(setlocale.o):(.text+0x3a5): undefined reference to `freeloca +le' libintl.a(setlocale.o):(.text+0x3aa): undefined reference to `__errno' libintl.a(setlocale.o):(.text+0x459): undefined reference to `newlocal +e' libintl.a(setlocale.o):(.text+0x55a): undefined reference to `newlocal +e' libintl.a(setlocale.o):(.text+0x346): undefined reference to `newlocal +e' libintl.a(loadmsgcat.o):(.text+0xb9): undefined reference to `mmap' libintl.a(loadmsgcat.o):(.text+0x2a7): undefined reference to `__errno +' libintl.a(loadmsgcat.o):(.text+0x45f): undefined reference to `munmap' libintl.a(loadmsgcat.o):(.text+0x9be): undefined reference to `munmap' libintl.a(localealias.o):(.text+0x9f): undefined reference to `__fsetl +ocking' libintl.a(localealias.o):(.text+0xbe): undefined reference to `fgets_u +nlocked' libintl.a(localealias.o):(.text+0xe5): undefined reference to `__local +e_ctype_ptr' libintl.a(localealias.o):(.text+0x11a): undefined reference to `__loca +le_ctype_ptr' libintl.a(localealias.o):(.text+0x134): undefined reference to `__loca +le_ctype_ptr' libintl.a(localealias.o):(.text+0x147): undefined reference to `__loca +le_ctype_ptr' libintl.a(localealias.o):(.text+0x17c): undefined reference to `__loca +le_ctype_ptr' libintl.a(localealias.o):(.text+0x2be): undefined reference to `fgets_ +unlocked' libintl.a(l10nflist.o):(.text+0x12b): undefined reference to `stpcpy' libintl.a(l10nflist.o):(.text+0x322): undefined reference to `argz_nex +t' libintl.a(l10nflist.o):(.text+0x40b): undefined reference to `stpcpy' libintl.a(l10nflist.o):(.text+0x424): undefined reference to `stpcpy' libintl.a(l10nflist.o):(.text+0x440): undefined reference to `stpcpy' libintl.a(l10nflist.o):(.text+0x460): undefined reference to `stpcpy' libintl.a(l10nflist.o):(.text+0x48d): undefined reference to `argz_str +ingify' libintl.a(l10nflist.o):(.text+0x4aa): undefined reference to `argz_cou +nt' libintl.a(l10nflist.o):(.text+0x55b): undefined reference to `__locale +_ctype_ptr' libintl.a(l10nflist.o):(.text+0x56a): undefined reference to `__locale +_ctype_ptr' libintl.a(l10nflist.o):(.text+0x5b5): undefined reference to `__locale +_ctype_ptr' libintl.a(l10nflist.o):(.text+0x5d1): undefined reference to `__locale +_ctype_ptr' libintl.a(l10nflist.o):(.text+0x5e3): undefined reference to `__locale +_ctype_ptr' libintl.a(plural-exp.o):(.text+0x5a): more undefined references to `__ +locale_ctype_ptr' follow collect2.exe: error: ld returned 1 exit status

      It seems another peace of code is missing (glibc maybe ? I'll have a look in MSY2 to see that)... But I still don't understand why the gcc -o test -lintl -I. test.c with libintl.a in the current directory doesn't work...

      ... and those undefined symbols should be defined by msvcrt ! And I neither can link with libintl.a on MSYS2.

        What does that mean? Can you compile link ANY C program at all?

        #include <string.h> int main(void){ char buf[10]; stpcpy(buf, "hello"); //sic }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-20 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found