On Nov 14, 2008, at 6:30 PM, Martin Dobias wrote:

libqgispython expects that dynamic linker loads the python library.
But I don't understand why we need to avoid it. Are python
implementations on OS X incompatible so that dynamic linker can't
choose any implementation?

There's dynamic linking and static linking for shared libraries. Generally, OSX expects static linking for libraries, and dynamic linking for plugins/modules.

Whenever you link with the compiler with -lfoo or -framework foo, it will be statically linked with a specific path (unlike Linux where I believe just the library name is stored in the binary and LD_LIBRARY_PATH and ld.conf set a search path).

Do you think that this will work? Let QGIS dynamically load python
library, and if loaded successfully, load also libqgispython? It makes
some sense to me but isn't this something that dynamic linker is
better suited to do?

So, yes, I'm suggesting dynamically linking Python instead of the normal static linking. OSX does have a DYLD_LIBRARY_PATH, but I'm not sure how that applies to frameworks, and it's not easily configured by the user for applications. Oh, I see DYLD_FRAMEWORK_PATH also (from dyld), but it doesn't appear that dlopen uses that.

You could try the known paths for the Python framework, and also make it configurable by the user as a Qgis preference. Then dlopen() that.


Hmmm... A possibility: compile and link statically as Qgis does now, use install_name_tool to change the python link to drop the path (this is how the Qt frameworks are initially). The linker at runtime then will use DYLD_FRAMEWORK_PATH and its internal default path to search for the python binary. A pseudo-dynamic linking, no need to fuss with dlopen() and searching for python or a preference. A user-installed python framework will override the system python, as expected.


Otherwise, whatever is done to make all the PyQt and Qgis python extensions "proper" won't matter, since libqgispython will be stuck with whichever
python it was compiled with.

So does this mean that both libqgispython and sip/pyqt/pyqgis share
the same problem that they link to a specific python?

Yes.

Btw. is there any good reading on web about these OSX-specific linking
issues in general to get a bigger image?


Xcode documentation (it's all online at Apple). GCC/LD man pages on an OSX Mac with Xcode have OSX-specific info also (they might also be on other systems).

A lot of the finer details is just my accumulation over the years ;)

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"Time is an illusion - lunchtime doubly so."

- Ford Prefect


_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to