<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>eksperimental</title>
	<link>http://eksperimental.net/blog</link>
	<description>development log of art.gnome.org 3</description>
	<pubDate>Mon, 09 Nov 2009 13:55:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>QGIS in OSX</title>
		<link>http://eksperimental.net/blog/2009/11/09/qgis-in-osx/</link>
		<comments>http://eksperimental.net/blog/2009/11/09/qgis-in-osx/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 13:41:39 +0000</pubDate>
		<dc:creator>Bruno Santos</dc:creator>
		
		<category><![CDATA[qgis]]></category>

		<guid isPermaLink="false">http://eksperimental.net/blog/2009/11/09/qgis-in-osx/</guid>
		<description><![CDATA[And after several(million) tries I finally was able to load a Vector Layer with the python Bindings.
So let me give you some background on the problem:
I was trying to run qgis 1.4.0 (current development version). The app runs just fine.
Python Bindings failed to load a vector layer and the only error message was &#8220;Failed to [...]]]></description>
			<content:encoded><![CDATA[<p>And after several(million) tries I finally was able to load a Vector Layer with the python Bindings.</p>
<p>So let me give you some background on the problem:</p>
<p>I was trying to run qgis 1.4.0 (current development version). The app runs just fine.<br />
Python Bindings failed to load a vector layer and the only error message was &#8220;Failed to load&#8221;.</p>
<p>Yeah, I noticed you failed, but can you please let me know why?</p>
<p>Most post I found about that problem says the qgis_prefx path is wrongly set up. Mine wasn&#8217;t.<br />
In my /etc/profile I have</p>
<pre>export QGISHOME=/Users/pheres/apps/qgis1.4.0.app/Contents/MacOS</pre>
<p>and in my code</p>
<pre>from qgis.core import *
import os
import sys
import pdb

prefix = os.getenv("QGISHOME")
QgsApplication.setPrefixPath(prefix, True)
QgsApplication.initQgis()
vlayer = QgsVectorLayer("test.shp", "test", "ogr")</pre>
<p>Well, but long story short, I just compiled QGIS again with BUILD_TYPE as DEBUG.<br />
(To do that you just add <em>-D CMAKE_BUILD_TYPE=Debug</em> to the <em>cmake</em> command.</p>
<p>With the debug I discovered the plugin libs weren&#8217;t being loaded.</p>
<pre>(QgsProviderRegistry) Checking  /Users/pheres/apps/qgis1.4.0.app/Contents/MacOS/lib/qgis/libogrprovider.so : ...invalid (lib not loadable)</pre>
<p>If we otool  the libs we will find something like this:<br />
<code>Kameo:qgis pheres$ otool -L libogrprovider.so<br />
libogrprovider.so:<br />
	QtCore.framework/Versions/4/QtCore (compatibility version 4.5.0, current version 4.5.2)<br />
	QtXml.framework/Versions/4/QtXml (compatibility version 4.5.0, current version 4.5.2)<br />
	/Library/Frameworks/GDAL.framework/Versions/1.6/GDAL (compatibility version 15.0.0, current version 15.1.0)<br />
	/Library/Frameworks/GEOS.framework/Versions/3/GEOS (compatibility version 4.0.0, current version 4.1.1)<br />
	@executable_path/lib/libqgis_core.1.4.0.dylib (compatibility version 1.4.0, current version 1.4.0)<br />
	QtGui.framework/Versions/4/QtGui (compatibility version 4.5.0, current version 4.5.2)<br />
	QtSvg.framework/Versions/4/QtSvg (compatibility version 4.5.0, current version 4.5.2)<br />
	QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.5.0, current version 4.5.2)<br />
	/Library/Frameworks/PROJ.framework/Versions/4.6/PROJ (compatibility version 6.0.0, current version 6.5.0)<br />
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)<br />
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)<br />
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)<br />
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)</code></p>
<p>The problem is in the <em>@executable_path/lib/libqgis_core.1.4.0.dylib</em>.<br />
In OSX the @executable_path doesn&#8217;t seams to work.</p>
<p>So to solve this I wrote this bash script to update the library paths in every file in the providers path.</p>
<pre>#!/usr/bin/env bash

version=$1
qgis_path=$2
file_to_change=$3

if [ "$file_to_change" = "." ]
then
file_to_change="*.so"
fi

for i in $file_to_change
do
    echo "updating $i"
    install_name_tool -change @executable_path/lib/libqgis_core.$version.dylib $qgis_path/lib/libqgis_core.$version.dylib  -change @executable_path/lib/libqgis_gui.$version.dylib $qgis_path/lib/libqgis_gui.$version.dylib -change @executable_path/lib/libqgis_analysis.$version.dylib $qgis_path/lib/libqgis_analysis.$version.dylib $i
done</pre>
<p>DISCLAIMER: You may freely use the above script, but with NO guarantees. I can ruin you computer for all that I know. USE AT YOUR OWN RISK.</p>
<p>Assurances aside, I basically had to change the library paths for each file using the install_name_tool.</p>
<p>This problem is related with the <a href="https://trac.osgeo.org/qgis/ticket/768">following ticket</a> in the QGIS Trac. </p>
]]></content:encoded>
			<wfw:commentRss>http://eksperimental.net/blog/2009/11/09/qgis-in-osx/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
