cancel
Showing results for 
Search instead for 
Did you mean: 

SAPRFC / PHP 5.3.0 / MacOSX Snow Leopard

Former Member
0 Kudos

<pre>(seems message parsing is not working..) Hello gurus !

I've read with a great interrest almost all posts on this forum, and I must say it helped me a lot sorting

out a nearly functional solution for installing SAPRFC PHP extension on a MacOSX Snow Leopard system.

It seems i'm just having a problem with the RFCSDK from SAP not being of the appropriate architecture.

Let me describe my installation process (maybe it can help other people willing to install SAPRFC on

Macintosh plateform equally !)

1. Installation of Macintosh developpement tools (Xcode)

First step was to install XCode Package, from http://developer.apple.com/tools/xcode/ it's a 650Mb

disk-image, that once installed is 2.5Gb on harddrive. This provided me with all php headers that I

needed for the next steps.

I made sure my Apache/PHP was functionnal on the Macintosh, this page helped me :

http://www.mac4ever.com/articles/creation/1153/php_mysql_sous_snow_leopard_et_xdebug_eclipse/ (it's in french)

2. Download of RFCSDK from SAP

I was not totally sure which version to install on my system since no "MacOsX version", so I picked

the "Linux on x86_64 64bit" package.

3. Extracting files from the SAR archive

As the binary of SAPCAR was not willing to execute properly, I downloaded a Windows version and

extracted my files on a Windows system.

4. Installing RFCSDK files on the system

I created a folder "sap" in folder "/usr" :

$> sudo mkdir /usr/sap

I created a folder "rfcsdk" in folder "/usr/sap"

$> sudo mkdir /usr/sap/rfcsdk

I copied all files i extracted from the SAR archive into the "/usr/sap/rfcsdk folder" :

$> sudo cp -R ~/Desktop/Linux\ on\ x86_64\ 64bit/ /usr/sap/rfcsdk/*

After this in "/usr/sap/rfcsdk" i have now : 4 folders : bin, include, lib and text

I changed access rights for all the files in sap directory:

$> sudo chmod -R 755 /usr/sap

5. Compiling SAPRFC extension for PHP

I downloaded SAPRFC 1.4.1 from http://saprfc.sourceforge.net/

I created a folder module under "/usr/sap" :

$> sudo mkdir "/usr/sap/module"

I unpacked the files from the saprfc-1.4.1.tar.gz archive into "/usr/sap/module/"

I ran phpize while in folder "/usr/sap/module/"

$> cd /usr/sap/module

$> sudo phpize

Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

(I made sure the phpize which was called was the one corresponding to the php version i was

running with apache, "locate phpize" helped me to sort out if there was serveral phpize that could

potentially be executed)

I ran then the configuration script

$> sudo ./configure

checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
../..
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged

Then i ran the compilation :

$> sudo make

/bin/sh /usr/sap/module/libtool --mode=compile cc  -I. -I/usr/sap/module -DPHP_ATOM_INC 
-I/usr/sap/module/include -I/usr/sap/module/main -I/usr/sap/module -I/usr/include/php 
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext 
-I/usr/include/php/ext/date/lib -I/usr/sap/rfcsdk/include  -DHAVE_CONFIG_H  -g -O2   
-c /usr/sap/module/saprfc.c -o saprfc.lo 
mkdir .libs
 cc -I. -I/usr/sap/module -DPHP_ATOM_INC -I/usr/sap/module/include -I/usr/sap/module/main 
-I/usr/sap/module -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend 
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/sap/rfcsdk/include -DHAVE_CONFIG_H -g -O2 -
c /usr/sap/module/saprfc.c  -fno-common -DPIC -o .libs/saprfc.o
/usr/sap/module/saprfc.c: In function '__callback_dispatch':
/usr/sap/module/saprfc.c:263: warning: format not a string literal and no format arguments
../..
/bin/sh /usr/sap/module/libtool --mode=compile cc  -I. -I/usr/sap/module -DPHP_ATOM_INC 
-I/usr/sap/module/include -I/usr/sap/module/main -I/usr/sap/module -I/usr/include/php 
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
 -I/usr/include/php/ext/date/lib -I/usr/sap/rfcsdk/include  -DHAVE_CONFIG_H  -g -O2   
-c /usr/sap/module/rfccal.c -o rfccal.lo 
 cc -I. -I/usr/sap/module -DPHP_ATOM_INC -I/usr/sap/module/include -I/usr/sap/module/main 
-I/usr/sap/module -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM 
-I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/sap/rfcsdk/include 
-DHAVE_CONFIG_H -g -O2 -c /usr/sap/module/rfccal.c  -fno-common -DPIC -o .libs/rfccal.o
/usr/sap/module/rfccal.c: In function 'cal_allocate':
/usr/sap/module/rfccal.c:36: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
/usr/sap/module/rfccal.c:50: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
/bin/sh /usr/sap/module/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/sap/module/include -I/usr/sap/module/main -
I/usr/sap/module -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend 
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/sap/rfcsdk/include  -DHAVE_CONFIG_H  -g -O2   
-o saprfc.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/sap/module/modules  
saprfc.lo rfccal.lo -Wl,-rpath,/usr/sap/rfcsdk/lib -L/usr/sap/rfcsdk/lib -lrfccm
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/saprfc.so -bundle  
.libs/saprfc.o .libs/rfccal.o  -L/usr/sap/rfcsdk/lib -lrfccm -Wl,-rpath -Wl,/usr/sap/rfcsdk/lib
+ld: warning: in /usr/sap/rfcsdk/lib/librfccm.so, file is not of required architecture+
creating saprfc.la
(cd .libs && rm -f saprfc.la && ln -s ../saprfc.la saprfc.la)
/bin/sh /usr/sap/module/libtool --mode=install cp ./saprfc.la /usr/sap/module/modules
cp ./.libs/saprfc.so /usr/sap/module/modules/saprfc.so
cp ./.libs/saprfc.lai /usr/sap/module/modules/saprfc.la
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/sap/module/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

And here seems the problem to be :

ld: warning: in /usr/sap/rfcsdk/lib/librfccm.so, file is not of required architecture

I continued anyway :

$> sudo make install

Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20090626/

6. Installing the PHP extension in the PHP.ini

I went to /etc and stated editing php.ini :

$> sudo vi /etc/php.ini

I went to the extensions part and added the line :

extension = "/usr/lib/php/extensions/no-debug-non-zts-20090626/saprfc.so"

+(for some reason, when setting extension = saprfc.so, i had some errors, while the

extension folder was defined to extensions/no-debug-non-zts-20090626 ... no clue

why, nevermind, works better with full path...)+

../..
;   extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.

extension     = "/usr/lib/php/extensions/no-debug-non-zts-20090626/saprfc.so"

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
;
;extension=php_bz2.dll
;extension=php_curl.dll
../..

I saved my php.ini file forcing write of the read only file (Esc, ":wq!", enter)

7. Testing the installation

I restarted my apache server, and checked /var/log/apache2/error_log; at this time no

error shows here yet.

I put the saprfc_test.php file in my Sites/ folder to test it with http://localhost// and the page

just load fine, and the php script seems to not fail on the test : if (! extension_loaded ("saprfc")),

so.. normally the extension is loaded by php.

After viewing the saprfc_test.php page, some errors appears in the /var/log/apache2/error_log :

dyld: lazy symbol binding failed: Symbol not found: _RfcGetAllLibVersions
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/saprfc.so
  Expected in: flat namespace

dyld: Symbol not found: _RfcGetAllLibVersions
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/saprfc.so
  Expected in: flat namespace

8. Trying to find out the issue

I wanted to run LDD tool on saprfc.so to find out if the linking was correctly done with the library

"/usr/sap/rfcsdk/lib/librfccm.so" but it appears that ldd is not available on MacOSX and Apple

recommand using "otool -L" instead.

Here we go :

*$> cd /usr/lib/php/extensions/no-debug-non-zts-20090626

*$> otool -L saprfc.so"

saprfc.so:

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)

Not very "verbose".. i tried the otool -l (minus L) to view any better info :

*$> otool -l saprfc.so"

saprfc.so:
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 552
  segname __TEXT
   vmaddr 0x0000000000000000
   vmsize 0x0000000000011000
  fileoff 0
 filesize 69632
../..
   vmaddr 0x0000000000013000
   vmsize 0x0000000000006000
  fileoff 73728
 filesize 22088
  maxprot 0x00000007
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 3
     cmd LC_UUID
 cmdsize 24
   uuid 0x21 0xea 0x9e 0x15 0xca 0x1c 0xd8 0xe8
        0x35 0x3e 0x54 0x86 0x3e 0x58 0xa1 0x8a
Load command 4
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 73728
    rebase_size 16
       bind_off 73744
      bind_size 1272
  weak_bind_off 0
 weak_bind_size 0
  lazy_bind_off 75016
 lazy_bind_size 2992
     export_off 78008
    export_size 1560
Load command 5
     cmd LC_SYMTAB
 cmdsize 24
  symoff 79568
   nsyms 575
  stroff 89760
 strsize 6056
Load command 6
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 405
     iextdefsym 405
     nextdefsym 75
      iundefsym 480
      nundefsym 95
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 88768
  nindirectsyms 247
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 7
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 125.0.0
compatibility version 1.0.0
Load command 8
          cmd LC_RPATH
      cmdsize 32
         path /usr/sap/rfcsdk/lib (offset 12)

OK this time, seems there is at least 1 mention of my RFCSDK in the last line, but .. just a path to the

lib folder, no mention to the library file it self.. i'm just a bit confused now !

Thank you for reading all this, now, maybe you if already managed to have a MacOSX SAPRFC

working or have any clue where I can find a RFCSDK library (or compilable sources) that would

just work on a Mac OSX system.. Thanks for your kind advices

Edited by: Lemmus on Dec 22, 2009 1:59 PM

Edited by: Julius Bussche on Dec 22, 2009 4:05 PM

Fixed formating a bit </pre>

Accepted Solutions (0)

Answers (1)

Answers (1)

Nigel_James
Active Contributor
0 Kudos

Hey that is one crazy message Lemmus. If you want people to respond a little human parsing and indenting maybe required.

I have one thought.

What version on SAP are you connecting to? If it is ECC6 or a netweaver system I would get hold of the sapnwrfc library. (Google is your friend)

It is designed to work with the new netweaver rfc interface.

Cheers,

Nigel

Former Member
0 Kudos

Hi Nigel and thanks for replying, I'm really sorry for the parsing, I made it all nice in the editor, but despite all my tries it wont apply it to the final message :'( it seems the forum engine will always remove the new lines codes.

If you right-click the page and display HTML source code you can view my post in the way I typed it in the edit box 😕

Edited by: Lemmus on Dec 22, 2009 3:53 PM

Former Member
0 Kudos

There is a limit of 2500 characters per post. This also prevents folks from dumping all their (or someone elses copy&pasted) code and huge trace files into the forums. There were also performance reasons.

I have seen a number of "workaround" for this limitation, but did not think of the view source option yet. Thanks for sharing

Cheers,

Julius