In a nutshell you need to compile your code with the same compiler that compiled perl. If you are using Active State Perl the compiler is cl.exe which is part of MSVC++. See A Practical Guide to Compiling C based Modules under ActiveState using Microsoft C++ for some hints.

It works fine for me using the setup described and cl.exe:

# Have a look at the options perl was built with (we don't need all of + them!)...... C:\>perl -MExtUtils::Embed -e ccopts -e ldopts -nologo -nodefaultlib -debug -opt:ref,icf -libpath:"D:\Perl\lib\COR +E" -machine:x86 D:\Perl\lib\CORE\perl56.lib D:\Perl\lib\CORE\oldnam +e s.lib D:\Perl\lib\CORE\kernel32.lib D:\Perl\lib\CORE\user32.lib D:\Per +l\lib\CORE\gdi32.lib D:\Perl\lib\CORE\winspool.lib D:\Perl\lib\CORE\c +o mdlg32.lib D:\Perl\lib\CORE\advapi32.lib D:\Perl\lib\CORE\shell32.lib +D:\Perl\lib\CORE\ole32.lib D:\Perl\lib\CORE\oleaut32.lib D:\Perl\lib\ +C ORE\netapi32.lib D:\Perl\lib\CORE\uuid.lib D:\Perl\lib\CORE\wsock32.li +b D:\Perl\lib\CORE\mpr.lib D:\Perl\lib\CORE\winmm.lib D:\Perl\lib\COR +E \version.lib D:\Perl\lib\CORE\odbc32.lib D:\Perl\lib\CORE\odbccp32.lib + D:\Perl\lib\CORE\msvcrt.lib -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DE +S_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_R +E ADFIX -I"D:\Perl\lib\CORE" # here is the code C:\>type interp.c #include <EXTERN.h> /* from the Perl distribution */ #include <perl.h> /* from the Perl distribution */ static PerlInterpreter *my_perl; /* The Perl interpreter */ int main(int argc, char **argv, char **env) { my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, NULL, argc, argv, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); } # Here are the flags that I passed to make it compile # Essentially we pass all the same -D defines that perl was built with + plus # the include dir to find the perl headers and the perl56.lib binary w +hich is # what where the real functions defined in the headers are found and w +hat we # will be linking against........ C:\>cl.exe -nologo -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT - +DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_ +MSVCRT_READFIX -I"D:\Perl\lib\CORE" D:\Perl\lib\CORE\perl56.lib -o +interp.exe interp.c interp.c # no messages, no errors, so let's test it...... C:\>interp.exe print "Hello World! It will work if you try hard enough.....\n"; ^D Hello World! It will work if you try hard enough..... C:\> # the bare minimum I needed to get a compile is this C:\>cl.exe -DWIN32 -I"D:\Perl\lib\CORE" D:\Perl\lib\CORE\perl56.lib -o + interp.exe interp.c Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.00.9466 for 80 +x86 Copyright (C) Microsoft Corporation 1984-2001. All rights reserved. interp.c Microsoft (R) Incremental Linker Version 7.00.9466 Copyright (C) Microsoft Corporation. All rights reserved. /out:interp.exe /out:interp.exe D:\Perl\lib\CORE\perl56.lib interp.obj C:\>interp.exe print "japh!\n"; ^D japh! C:\>

cheers

tachyon


In reply to Re: Perl & borland 5.5 C/C++ Compiler by tachyon
in thread Perl & borland 5.5 C/C++ Compiler by Nalina

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.