Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Import a DLL from C# to Perl

by RonW (Parson)
on May 08, 2018 at 21:07 UTC ( #1214231=note: print w/replies, xml ) Need Help??

in reply to Import a DLL from C# to Perl

With this code I was able to call the dll from a C code.

This C program you wrote to call your C++ wrapper that calls the C# function, did you build this C program using Visual Studio?

You don't mention which distribution of Perl you are using. Even on MS Windows, Perl is usually not built using Visual Studio. And since XS modules and Inline::C (and other Inline:: code) need to be built with the same tool chain as Perl was built with, presumably the XS, Inline::C or Inline::CPP code was not built with Visual Studio.

Maybe this Compiling perl on windows with visual studio thread is helpful to you.

Update: syphilis is correct in pointing out that Win32::API would not have been built with Visual Studio, either. What I neglected, though someone else did mention, is that C# uses .NET as well as the Windows API. According to a friend of mine, building .NET applications without Visual Studio can be very hard.

Replies are listed 'Best First'.
Re^2: Import a DLL from C# to Perl
by syphilis (Bishop) on May 09, 2018 at 00:08 UTC
    presumably the XS, Inline::C or Inline::CPP code was not built with Visual Studio

    And nor would Win32::API have been built with Visual Studio.
    This could definitely pose problems.

    Could paulorfmmb please check which compiler is being used by perl. (Running perl -V:cc will provide that info.)
    In fact, probably best to give us the full perl -V output.

      Here is perl -V output
      Summary of my perl5 (revision 5 version 26 subversion 2) configuration +: Platform: osname=MSWin32 osvers=10.0.16299.371 archname=MSWin32-x86-multi-thread-64int uname='Win32 strawberry-perl #1 Sun Apr 15 11:47:13 2018 +i386' config_args='undef' hint=recommended useposix=true d_sigaction=undef useithreads=define usemultiplicity=define use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='gcc' ccflags =' -s -O2 -DWIN32 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE +_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fw +rapv -fno-strict-aliasing -mms-bitfields' optimize='-s -O2' cppflags='-DWIN32' ccversion='' gccversion='7.1.0' gccosandvers='' intsize=4 longsize=4 ptrsize=4 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=12 longdblkind=3 ivtype='long long' ivsize=8 nvtype='double' nvsize=8 Off_t='long long' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='g++' ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"' libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\i686-w64-mingw32\lib C:\STR +AWB~1\c\lib\gcc\i686-w64-mingw32\7.1.0 libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 + -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 - +lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomd +lg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_ +32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 libc= so=dll useshrplib=true libperl=libperl526.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs dlext=xs.dll d_dlsymun=undef ccdlflags=' ' cccdlflags=' ' lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c +\lib"' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Apr 15 2018 11:51:03 @INC: C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2019-06-19 20:54 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (89 votes). Check out past polls.