Link to home
Start Free TrialLog in
Avatar of mhenwood
mhenwood

asked on

Problems Installing PyQt on OS X 10.6.3

I am trying to install PyQt on a Mac equiped with OSX 10.6.3.  I have the mac developer tools loaded and seemed to install Qt and the sip packages without a problem but I keep getting link errors when I try to compile PyQt.  Below is the output from (I believe) the start of the errors:

rm -f libpythonplugin.dylib
g++ -headerpad_max_install_names -single_module -dynamiclib -o libpythonplugin.dylib pluginloader.o moc_pluginloader.o  -F/Library/Frameworks -L/Library/Frameworks -framework Python -framework QtDesigner -framework QtScript -framework QtXml -framework QtGui -framework QtCore  
ld: warning: in /Library/Frameworks/Python.framework/Python, missing required architecture x86_64 in file
Undefined symbols:
  "_Py_Initialize", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyLong_AsVoidPtr", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyErr_Print", referenced from:
      PyCustomWidgets::getModuleAttr(char const*, char const*)in pluginloader.o
      PyCustomWidgets::getModuleAttr(char const*, char const*)in pluginloader.o
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyString_FromString", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyType_IsSubtype", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyModule_GetDict", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyObject_CallObject", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyObject_CallFunctionObjArgs", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyList_Append", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_Py_IsInitialized", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyDict_Next", referenced from:
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyImport_ImportModule", referenced from:
      PyCustomWidgets::getModuleAttr(char const*, char const*)in pluginloader.o
      PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
  "_PyObject_GetAttrString", referenced from:
      PyCustomWidgets::getModuleAttr(char const*, char const*)in pluginloader.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [libpythonplugin.dylib] Error 1
make: *** [all] Error 2

I have installed:
qt-mac-cocoa-opensource-4.6.3.dmg
sip-4.10.2 (compile and install)
and am trying to compile and install PyQt-mac-gpl-4.7.3.  

Any suggestions on how to get this working?
Mark
Avatar of mhenwood
mhenwood

ASKER

Why do I need to make a comment here to submit my question?
Searching on  "missing required architecture x86_64" lead to an answer for another project that suggested adding "-arch x86_64" but I have had no joy in trying to add this.  I have put it in the pyqtconfig.py file which "python configure.py" creates but it seemed to have no effect.  
Mark
Avatar of evilrix
The GNU linker is very fussy about the order you link things. It must see dependants (things that want symbols) before libraries/object files that can satisfy those dependants. The reason is the linker only pulls out the symbols it knows it needs and once it's seen a library it won't go back to it.

http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html
http://www.network-theory.co.uk/docs/gccintro/gccintro_17.html

I notice your errors are that pluginloader is referencing something the linker cannot find and I'd guess these are to be found in libpythonplugin.dylib so try changing your linking order to link pluginloader first and then libpythonplugin.
Let me know if the above doesn't help and I'll work with you to do some more digging. I am slightly disadvantaged since I don't have a Mac but I do have Linux and OSX is really just Linux under the hood :)
I have spent a few hours trying to sort through the Make files built by python but I am still not sure where to change the order of linking.  
Using grep the only instance I can find of the first missing symbol "Py_Initialize" is in designer/pluginloader.cpp and its object file but I am not sure how to change the build order (the curse of ide's)
Also I found there is a switch in the configure.py to turn QTDesigner off.  That got me through the build but when I tried to use QT I get the following:

henmac:GuiPython mhenwood$ python SignalsAndSlots.py
Traceback (most recent call last):
  File "SignalsAndSlots.py", line 3, in <module>
    from PyQt4.QtCore import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyQt4/QtCore.so, 2): no suitable image found.  Did find:
      /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyQt4/QtCore.so: mach-o, but wrong architecture

This leads me to believe the warning in my original post:
ld: warning: in /Library/Frameworks/Python.framework/Python, missing required architecture x86_64 in file

Has merit there is a configuration.py switch for arch but it does not seem to have any effect when I use it. I have tried the following as well as each by itself with the same outcome.  

python configure.py --use-arch=x86_64 --no-designer-plugin

That is if --no-designer-plugin is defined PyQt builds but throws the above error regardless of the --use-arch switch and if the --no-designer-plugin switch is not used then the build pukes (technical term).

I have PyQt working on Debian 64 bit and windows 32 bit but my laptop is a Mac and I would like to figure out how to use it in development.

Any thoughts?

Mark
The order of linking is going to be controlled by the Makefile but if this isn't one you've written but one that comes with the product it is probably correct.

As for the error "missing required architecture x86_64", if this was Linux I'd be asking you to check you have the correct version of binutils installed. There is a different version for each target platform.

http://www.gnu.org/software/binutils/
http://en.wikipedia.org/wiki/GNU_Binutils

Not sure if this is applicable for the Mac OSX.
The recommendation for OS X is to install the "X Code" tools which are Apples development tools.  Running ld -v gives
henmac:~ mhenwood$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-97.2
llvm version 2.6svn,  Apple Build #2207-05

so it seems to know its Apple and 64 bit.  I can't help thinking I am missing something monumentally easy as there are only two kinds of problems that drag out like this.  Ones with simple "well duh" type answers and rocket science problems where you need education, time, and money to effect a solution.  Given the context (PyQt on the Mac) I don't figure there are any rockets involved.  
The basic path is
1. Install the X Code Tools
2. Compile & install QT
3. Compile & install sip - Sip seems to be a translation of some type between Py an Qt proper.
4. Complie & install PyQt.

Steps 1 through 3 worked out as expected but the last step as you know fails.  The Version numbers for the different sources all seem to check out fine and I just don't know where to go from here,

I have tried rebuilding and reinstalling sip but with no change in the final outcome.

Any strokes of brilliance would be greatly appreciated !
Mark
At this point I don't really know what else to suggest... I don't have access to nor have I ever used a Mac. I was hoping that since the compiler is gcc and the linker ld (I am very familiar with both) I'd be able to assist you but it seems not :(

Last but really dumb questions - you are definitely trying to link against libraries that are correct for your architecture? I mean, you didn't accidentally download the wrong ones did you? Long shot but, heh, I've done dafter things myself :)

If that doesn't help I'll all out really - sorry.
Well,
Having tried everything again, PyQt now says my copy of Qt is 32 bit.  It is the only source available for the Mac sooo.... Do you have any idea what the --use-arch= would be looking for to compile in 32 bit, or is this the wrong approach?

Mark
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, you were right about the i386 switch.  And about the libraries I was linking against (32 vs 64 bit)  Unfortunately I still cant get a good build on OS X.  I appreciate the time and effort you have spent trying to get me over this hump.  I still can't believe no one else has had these problems (rant rave etc.)
Thanks for the help.
>> Well, you were right about the i386 switch.  And about the libraries I was linking against

Whilst it's nice to know I was right and we've moved you on a little it is no comfort to know that I didn't actually solve your issue for you. I hate having to say "I can't help any more" but on this occasion I think I've reached my depth with Mac OSX and anything else I try and figure out would be pure conjecture on my part.

If you do manage to resolve this you'd be doing everyone a great favour if you could post the solution here. I'd have no issue with this being reopened and your real solution being accepted as the answer.

Best of luck and sorry I couldn't be more help.

-Rx.