Pardon if "32-bit" is archeology in 2020, it's just that I have some time to debug/develop at that machine -- but can pursue other projects, while postponing this one till later. I.e., question is not urgent/critical, simply puzzling.

Using FreeImage DLL, this C test runs perfectly well:

#include <stdio.h> #include <stdlib.h> #include <FreeImage.h> int main( int argc, char **argv ) { printf("%s\n", FreeImage_GetVersion()); FIBITMAP *im = FreeImage_Load(FreeImage_GetFileType(argv[1], 0), a +rgv[1], 0); printf("%d\n", im); FITAG *tag = FreeImage_CreateTag(); FreeImage_SetTagKey(tag, "Urgency"); FreeImage_SetTagLength(tag, 2); FreeImage_SetTagCount(tag, 2); FreeImage_SetTagType(tag, FIDT_ASCII); FreeImage_SetTagValue(tag, "5"); printf("*\n"); FreeImage_SetMetadata(FIMD_IPTC, im, FreeImage_GetTagKey(tag), tag +); printf("*\n"); FreeImage_DeleteTag(tag); FreeImage_Unload(im); }
>convert wizard: wiz.jpg >convert wizard: wiz.tif >gcc -s -O2 -DWIN32 -fwrapv -fno-strict-aliasing -mms-bitfields -o fit +est.exe fitest.c -lfreeimage >fitest.exe wiz.jpg 3.18.0 2729184 * * >fitest.exe wiz.tif 3.18.0 2728264 * *

However, this Perl script fails:

use strict; use warnings; use FindBin; load( $ARGV[0] ); use Inline C => config => inc => "-I$FindBin::Bin", libs => "-L$FindBin::Bin -lfreeimage"; use Inline C => <<'END_OF_C'; #include <FreeImage.h> void load(char *fname) { // FreeImage_Initialise(FALSE); printf("%s\n", FreeImage_GetVersion()); FIBITMAP *im = FreeImage_Load(FreeImage_GetFileType(fname, 0), fna +me, 0); printf("%d\n", im); FITAG *tag = FreeImage_CreateTag(); FreeImage_SetTagKey(tag, "Urgency"); FreeImage_SetTagLength(tag, 2); FreeImage_SetTagCount(tag, 2); FreeImage_SetTagType(tag, FIDT_ASCII); FreeImage_SetTagValue(tag, "5"); printf("*\n"); FreeImage_SetMetadata(FIMD_IPTC, im, FreeImage_GetTagKey(tag), tag +); printf("*\n"); FreeImage_DeleteTag(tag); FreeImage_Unload(im); // FreeImage_DeInitialise(); } END_OF_C __END__ >perl fitest.pl wiz.jpg 3.18.0 2733096 * >perl fitest.pl wiz.tif 3.18.0

Perl crashes, hence truncated output -- with call to "FreeImage_SetMetadata" for jpg image, and "FreeImage_Load" for tif image. "FreeImage_Initialise" makes no difference (manual says, it's not required to be called), and same compiler options, which Inline uses, work perfect for pure C, above. There is no such issue for 64 bit environment (of course, a dll of appropriate architecture was used in both cases). Why is this happening and can it be (easily) fixed?


In reply to Errors using DLL from Inline C with 32-bit Perl by vr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.