in reply to Perl & borland 5.5 C/C++ Compiler
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl & borland 5.5 C/C++ Compiler
by blm (Hermit) on Aug 24, 2004 at 12:03 UTC | |
by tachyon (Chancellor) on Aug 24, 2004 at 12:31 UTC | |
by blm (Hermit) on Aug 24, 2004 at 13:09 UTC | |
by tachyon (Chancellor) on Aug 24, 2004 at 13:22 UTC | |
by blm (Hermit) on Aug 24, 2004 at 13:34 UTC |
In Section
Seekers of Perl Wisdom