Skip to Content
Author's profile photo Florian Wiedemann

Compile Perl cpan module sapnwrfc from source code on Windows 64 bit

It took me some time to get a working Perl module sapnwrfc to call RFC capable SAP function modules within Perl. Several tries with different software versions (ActiveState Perl, StrawBerry Perl 32 vs. 64 bit, SAP NW RFC SDK and different compilers like MinGW and Microsoft C compiler) were not successfull. With the following steps I succeeded finally. 🙂


Install a current Strawberry Perl 64 bit package from In my case it was

Download the current version of the SAP NW RFC SDK x64 bit from

You can find it with the following categories:

Support Packages and Patches => By Category => Additional Components => SAP NW RFC SDK => SAP NW RFC SDK 7.20

In my case the current version was 7.20 PL42 x64.

Extract the downloaded file with sapcar -xvf NWRFC_42-20004568.SAR

I renamed the folder to C:\nwrfcsdk_x64.

Create .def and .a files for the MinGW compiler / linker with the following commands in the directory C:\nwrfcsdk_x64:

gendef *.dll
dlltool –dllname icuin34.dll –def icuin34.def –output-lib icuin34.a
dlltool –dllname icudt34.dll –def icudt34.def –output-lib icudt34.a
dlltool –dllname icuuc34.dll –def icuuc34.def –output-lib icuuc34.a
dlltool –dllname libsapucum.dll –def libsapucum.def –output-lib libsapucum.a
dlltool –dllname libicudecnumber.dll –def libicudecnumber.def –output-lib libicudecnumber.a
dlltool –dllname sapnwrfc.dll –def sapnwrfc.def –output-lib sapnwrfc.a


Start command prompt with cmd.exe and start the program cpan.

Start the command get sapnwrfc to download the Perl module sapnwrfc from CPAN.

Leave the cpan environment with the exit command. Change directory to C:\Strawberry\cpan\build\sapnwrfc-0.37-0.

Build the Makefile(s) with the following command. Adapt the folder names according to your setup.

perl Makefile.PL –source=C:\nwrfcsdk_x64 –addlibs “C:\nwrfcsdk_x64\lib\sapnwrfc.a C:\nwrfcsdk_x64\lib\libsapucum.a”


Use a simple example like from to test the installation:

use strict;
use warnings;
use utf8;
use sapnwrfc;

my $conn = SAPNW::Rfc->rfc_connect;

my $rd = $conn->function_lookup("RPY_PROGRAM_READ");
my $rc = $rd->create_function_call;

eval {
if ($@) {
    die "RFC Error: $@\n";

print "Program name: ".$rc->PROG_INF->{'PROGNAME'}."\n";
my $cnt_lines_with_text = scalar grep(/LGRFCUXX/, map { $_->{LINE} } @{$rc->SOURCE_EXTENDED});


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.