[PyKDE] problem with libsip on AIX

Ulrich Berning ulrich.berning at t-online.de
Thu Sep 11 15:16:01 BST 2003


Michal Drozd wrote:

> Hi all,
>
> I have a problem importing libsip during startup of a python/qt 
> application on AIX 5.1.
>
> Some background:
> I am trying to get a GUI running on several platforms.  The 
> application was originally developed using python and qt on Solaris 
> and Windows, with future platform support in mind.  So far, I have 
> managed to get it working on HP-UX 11, without major obstacles.
>
> On AIX, everything started fairly well - I only had to modify few 
> makefiles to add python2.2 to the LIBS list for the tools to build 
> (maybe this was a first indication of some mistake on my part - 
> shouldn't libpython2.2 be included in the LIBS list if it was necessary?).
>
> Once I had all the supporting tools and libraries built, my app built 
> without problems.
> But an attempt to run the application resulted in "ImportError: no 
> module named libsip" from qt.py, line "import libsip"
>
> A quick investigation revealed that python searches for libsip.so, but 
> the sip installation only created a link libsip.a -> libsip.so.10.1.0
>
> I tried creating libsip.so -> libsip.so.10.1.0, just to see what would 
> happen, and got a Segmentation Fault on "import libsip"
>
> It appears that my sip library is not built correctly for use on AIX, 
> but I cannot figure out what I am doing wrong.
>
> Can anyone help me out with this problem?  Is anyone using 
> python/qt/sip/pyqt on AIX? (there does not seem to be many AIX related 
> posts in the arvchive).
>
> My configuration:
> - AIX 5.1
> - python 2.2.3
> - Qt 3.1.2
> - sip 3.7
> - PyQt 3.7
> - qscintilla 1.53
>
> All tools were built with --prefix=... (since I cannot write to 
> /usr/local), python was built with --disable-ipv6 and qt was built 
> with -thread.  Other than that, default settings were used.
>
> Thanks in advance,
>         Michal
>
For AIX 4.3.3 the story is, a shared library on AIX is an archive 
library containing a shared object, not the shared object itself. I 
think this is the same for AIX 5.1. To create real shared objects, you 
have to change the 'dll' template to 'plugin' in the *.pro files of sip 
and PyQt. If you do this, you have the next problem, because the linker 
searches for *.a and not for *.so files by default, you have to enable 
runtime linking to do this. This means, that you also have to enable 
runtime linking for Python.
I had success building Python/Qt/sip/PyQt with VisualAge C++ V6.0 on AIX 
4.3.3. If you are using VisualAge C++, the attached patches contain the 
neccessary changes for Python-2.3, sip-3.8 and PyQt-3.8.1 (This should 
also work for Python-2.2.3, sip-3.7 and PyQt-3.7) . If you are using GNU 
g++, the patches may give you at least some hints how to solve the problem.

To understand the whole story read 
http://www.redbooks.ibm.com/abstracts/sg245674.html (specially the 
chapter about runtime linking).

Python was configured with the following command:

CC="xlc_r" CXX="xlC_r" LIBS="-lC" ./configure --with-threads 
--with-cxx=xlC_r --prefix=/usr/local

When building PyQt you will get a lot of warning messages about 
duplicate symbols, simply ignore them. After building, it is safe to 
strip the libqt*cmodule.so files.

Good luck,
Ulli




-------------- next part --------------
diff -uNr Python-2.3.orig/configure Python-2.3/configure
--- Python-2.3.orig/configure	2003-07-24 00:17:27.000000000 +0200
+++ Python-2.3/configure	2003-09-11 12:50:30.000000000 +0200
@@ -1377,6 +1377,9 @@
   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
   SCO_SV/3.2)
     define_xopen_source=no;;
+  #
+  AIX/4*)
+    define_xopen_source=no;;
 esac
 
 if test $define_xopen_source = yes
@@ -1473,7 +1476,8 @@
 else
 
 	case $ac_sys_system in
-	AIX*)   CC=cc_r
+	AIX*)   CC=xlc_r
+                OPT="$OPT -O2 -qmaxmem=8000"
 		without_gcc=;;
 	BeOS*)
 		case $BE_HOST_CPU in
@@ -3213,7 +3217,7 @@
 		   $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
 	       exp_extra="."
 	   fi
-	   LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
+ 	   LINKCC="CreateExportList Modules/python.exp \$(LIBRARY); $LINKCC";;
 	dgux*)
 	   LINKCC="LD_RUN_PATH=$libdir $LINKCC";;
 	Monterey64*)
@@ -9602,8 +9606,8 @@
 then
 	case $ac_sys_system/$ac_sys_release in
 	AIX*)
-		BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
-		LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
+		BLDSHARED="ld -bnoentry -G -bexpall -lc -lm"
+	        LDSHARED="ld -bnoentry -G -bexpall -lc -lm"
 		;;
 	BeOS*)
 		BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
@@ -9709,7 +9713,7 @@
 if test -z "$LINKFORSHARED"
 then
 	case $ac_sys_system/$ac_sys_release in
-	AIX*)	LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
+	AIX*)	LINKFORSHARED='-brtl -bE:Modules/python.exp';;
 	hp*|HP*)
 	    LINKFORSHARED="-Wl,-E -Wl,+s";;
 #	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
@@ -10099,10 +10103,11 @@
 case "$ac_sys_system" in
 	AIX*)	echo "$as_me:$LINENO: checking for genuine AIX C++ extensions support" >&5
 echo $ECHO_N "checking for genuine AIX C++ extensions support... $ECHO_C" >&6
+                LIBS="-lC $LIBS"
 		cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-#include "/usr/lpp/xlC/include/load.h"
+#include <load.h>
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
      extern "C"
@@ -12347,7 +12352,7 @@
 if test -z "$DYNLOADFILE"
 then
 	case $ac_sys_system/$ac_sys_release in
-	AIX*) DYNLOADFILE="dynload_aix.o";;
+	AIX*) DYNLOADFILE="dynload_shlib.o";;
 	BeOS*) DYNLOADFILE="dynload_beos.o";;
 	hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
 	Darwin/*) DYNLOADFILE="dynload_next.o";;
-------------- next part --------------
diff -uNr sip-x11-commercial-3.8.orig/build.py sip-x11-commercial-3.8/build.py
--- sip-x11-commercial-3.8.orig/build.py	2003-08-17 11:24:16.000000000 +0200
+++ sip-x11-commercial-3.8/build.py	2003-09-11 12:44:48.000000000 +0200
@@ -45,7 +45,7 @@
 debugMode = "release"
 licType = None
 gccFlags = []
-blx_config = ["dll"]
+blx_config = ["plugin"]
 
 
 def usage(rcode = 2):
@@ -1098,12 +1098,21 @@
     fixInstallTarget()
     popDir(olddir)
 
+    global platPyLibDir, platPyLibName
+    if sys.platform == 'aix4':
+        makefilePatches["LINK"] = [re.compile("(^LINK.*)$",re.M), "LINK = cc -qmkshrobj=0 -G "]
+        makefilePatches["LINK_TARGET"] = [re.compile("(^[ \\t]*makeC\\+\\+SharedLib.*)$",re.M), '\t$(LINK) -o $(TARGET) $(LFLAGS) $(OBJECTS) $(OBJMOC) $(LIBS)']
+
     inform("Creating SIP module Makefile.")
     olddir = pushDir("siplib")
     buildMakefile("siplib.pro")
     fixInstallTarget(1)
     popDir(olddir)
 
+    if sys.platform == 'aix4':
+        del makefilePatches["LINK"]
+        del makefilePatches["LINK_TARGET"]
+
     # Generate the top-level Makefile.
     inform("Creating top level Makefile.")
     copyToFile("sip.pro.in","TEMPLATE = subdirs\nSUBDIRS = sipgen siplib\n")
-------------- next part --------------
diff -uNr PyQt-x11-commercial-3.8.1.orig/build.py PyQt-x11-commercial-3.8.1/build.py
--- PyQt-x11-commercial-3.8.1.orig/build.py	2003-09-06 15:36:16.000000000 +0200
+++ PyQt-x11-commercial-3.8.1/build.py	2003-09-11 12:59:40.000000000 +0200
@@ -839,7 +839,7 @@
     elif sipVersion == 4:
         proPatches["DLL"] = [re.compile("@BL_DLL@",re.M), "plugin"]
     else:
-        proPatches["DLL"] = [re.compile("@BL_DLL@",re.M), "dll"]
+        proPatches["DLL"] = [re.compile("@BL_DLL@",re.M), "plugin"]
         proPatches["LIBS"] = [re.compile("@BL_SIPMODDIR@",re.M), escape(sipModuleDir)]
 
     # Check the Qt installation.
@@ -1184,6 +1184,13 @@
         else:
             target = target + "module"
 
+    if sys.platform == 'aix4':
+        add_opt = ""
+        if mname == "qt":
+            add_opt = "-Wl,-bbigtoc"
+        makefilePatches["LINK"] = [re.compile("(^LINK.*)$",re.M), "LINK = cc -qmkshrobj=0 -G %s " % add_opt]
+        makefilePatches["LINK_TARGET"] = [re.compile("(^[ \\t]*makeC\\+\\+SharedLib.*)$",re.M), '\t$(LINK) -o $(TARGET) $(LFLAGS) $(OBJECTS) $(OBJMOC) $(LIBS)']
+
     # Generate the Makefile.
     inform("Generating the Makefile for the %s module." % (mname))
 
@@ -1206,6 +1213,10 @@
     except:
         pass
 
+    if sys.platform == 'aix4':
+        del makefilePatches["LINK"]
+        del makefilePatches["LINK_TARGET"]
+
     if sipVersion == 3:
         # Compile the Python part of the module.
         pyname = mname + ".py"


More information about the PyQt mailing list