Re: Would like some help fixing bug in TclMagick

Computer Jock <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Organization Digital Liar
Message-ID <[email protected]>
I'm curious, why the change:

2016-12-31  Bob Friesenhahn  <[email protected]>

     * generic/Makefile.am: Applied patch by Massimo Manghi (plus some
     fixes by me) to add a 'libttkcommon' shared library to contain
     codde common to the TclMagick/TkMagick loadable modules, and
     particularly to allow TkMagick to access TclMagick functions
     without depending on dlopen() with RTLD_GLOBAL behavior.

If a DLL or SO could not refer to functions defined in a dependent 
DLL/SO, how would anything work? ie. On windows (using dll's from 
Msys2/MinGW):

$ ldd gm.exe
            :
         libfreetype-6.dll => /mingw64/bin/libfreetype-6.dll (0x693c0000)
         libharfbuzz-0.dll => /mingw64/bin/libharfbuzz-0.dll (0x61600000)
           :
         libpng16-16.dll => /mingw64/bin/libpng16-16.dll (0x68b40000)
         zlib1.dll => /mingw64/bin/zlib1.dll (0x62e80000)
           :

I know that freetype uses functions in harfbuzz and png uses functions 
in zlib. When one links in windows (I've forgotten how it works in 
unix), one links against the DLL export library.

[I need a DLL that does not refer to mingw DLL's, so I built 
GraphicsMagick static libraries and the same for freetype so my 
Tcl/TkMagick.dll's do not use the DLL's from mingw64 but only those in 
C:/windows]

Here's how I linked Tcl/Tk Magick:

   gcc -shared -static-libgcc -o TclMagick.dll \
     \
     -Wl,--subsystem,windows,--out-implib,TclMagick.dll.a \
     \
     $tclMagick/generic/.libs/libTclMagick_la-TclMagick.o \
     -LPREFIX/lib -lGraphicsMagickWand -lGraphicsMagick \
     \
     -Wl,-Bstatic \
     -ltiff -lfreetype -ljpeg -lpng16 -llzma -lbz2 -lz -lwinpthread \
     -Wl,-Bdynamic \
     \
     -L$TCL/lib -ltclstub86 \
     -lgdi32

   gcc -shared -static-libgcc -o TkMagick.dll \
     $tclMagick/generic/.libs/libTkMagick_la-TkMagick.o \
     TclMagick.dll.a \
     -L$TCL/lib -ltkstub86

TkMagick.dll has no problems using findMagickObj() in TclMagick.dll

$ ldd TclMagick.dll
         ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x779e0000)
         kernel32.dll => /c/Windows/system32/kernel32.dll (0x777c0000)
         KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll 
(0x7fefda60000)
         ADVAPI32.dll => /c/Windows/system32/ADVAPI32.dll (0x7fefde70000)
         msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefdfa0000)
         sechost.dll => /c/Windows/SYSTEM32/sechost.dll (0x7feffbf0000)
         RPCRT4.dll => /c/Windows/system32/RPCRT4.dll (0x7fefe580000)
         GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefdae0000)
         USER32.dll => /c/Windows/system32/USER32.dll (0x778e0000)
         LPK.dll => /c/Windows/system32/LPK.dll (0x7fefe360000)
         USP10.dll => /c/Windows/system32/USP10.dll (0x7fefdbf0000)
         IMM32.DLL => /c/Windows/system32/IMM32.DLL (0x7fefde40000)
         MSCTF.dll => /c/Windows/system32/MSCTF.dll (0x7fefe1d0000)

$ ldd TkMagick.dll
         ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x779e0000)
         kernel32.dll => /c/Windows/system32/kernel32.dll (0x777c0000)
         KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll 
(0x7fefda60000)
         msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefdfa0000)
         TclMagick.dll => 
/c/Users/imdave/Desktop/GraphicsMagick/PREFIX/lib/TclMagick0.46/TclMagick.dll 
(0x69c00000)
         ADVAPI32.dll => /c/Windows/system32/ADVAPI32.dll (0x7fefde70000)
         sechost.dll => /c/Windows/SYSTEM32/sechost.dll (0x7feffbf0000)
         RPCRT4.dll => /c/Windows/system32/RPCRT4.dll (0x7fefe580000)
         GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefdae0000)
         USER32.dll => /c/Windows/system32/USER32.dll (0x778e0000)
         LPK.dll => /c/Windows/system32/LPK.dll (0x7fefe360000)
         USP10.dll => /c/Windows/system32/USP10.dll (0x7fefdbf0000)
         IMM32.DLL => /c/Windows/system32/IMM32.DLL (0x7fefde40000)
         MSCTF.dll => /c/Windows/system32/MSCTF.dll (0x7fefe1d0000)
$ ls -l *.dll
-rwxr-xr-x 1 imdave None 4562944 Apr 14 00:43 TclMagick.dll
-rwxr-xr-x 1 imdave None  181760 Apr 14 00:43 TkMagick.dll

and my pkgIndex.tcl file:

   package ifneeded TclMagick 0.46 "
       if { ! [info exists ::env(MAGICK_CONFIGURE_PATH)] } {
     [list set ::env(MAGICK_CONFIGURE_PATH) [file join $dir config]]
       }
       [list load [file join $dir TclMagick[info sharedlibextension]]]"

   package ifneeded TkMagick 0.46 "
       package require Tk
       package require TclMagick
       [list load [file join $dir TkMagick[info sharedlibextension]]]"

Again, I'm just curious. I am by >no< means any expert on windows stuff.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.