Cross compile with LAPACK library on Nokia N9: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= | [toc align_right="yes&quot; depth="3&quot;]<br />[[Category:Developing_with_Qt::Harmattan]]<br />[[Category:Developing_with_Qt::Workarounds]] | ||
= | = Cross compile a Qt program for Harmattan using the LAPACK library = | ||
== Summary == | |||
"LAPACK&quot;:http://www.netlib.org/lapack/#_presentation provides routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems. It is written in Fortran 90. | |||
It is not obvious how to link against LAPACK when cross-compiling a program for use on a Harmattan device as the 'official' method doesn't seem to work as expected. | |||
Workarounds seem to be required both for obtaining the libraries and for cross-compiling the program. An interpretation of the 'official' method, and a workaround method, are included below. This method is based on the method by avieli "here&quot;:http://talk.maemo.org/showpost.php?p=1103831&amp;postcount=9. | |||
Ideally the Nokia Qt Creator Harmattan | == Method 1: The 'Official' Method == | ||
Ideally the Nokia Qt Creator Harmattan SDK would come with LAPACK, BLAS and GFORTRAN libararies as standard. However, this does not appear to be the case. If it were you should then be able to add the following lines of code to your project file: | |||
<code> CONFIG+=link_pkgconfig<br /> PKGCONFIG+=libblas<br /> PKGCONFIG+=liblapack<br /> PKGCONFIG+=libgfortran<br /></code> | |||
QMake would then create a makefile and the libraries would be automatically linked when compilation took place. | QMake would then create a makefile and the libraries would be automatically linked when compilation took place. | ||
Line 17: | Line 21: | ||
At the moment the problems seem to be: | At the moment the problems seem to be: | ||
# These libraries are not in the standard Nokia Qt Creator | # These libraries are not in the standard Nokia Qt Creator SDK install (with Harmattan options selected) - they have to be downloaded and pkg-config files constructed manually; | ||
# QMake does not seem to correctly construct the makefile with references to these libraries | # QMake does not seem to correctly construct the makefile with references to these libraries - it only references the directories where these libraries reside (i.e. my makefile did not include the '<s>l' statements which referenced the specific libraries.) | ||
<br />h2. Method 2: The 'Workaround' Method | |||
<br />This method is based on the method by avieli "here&quot;:http://talk.maemo.org/showpost.php?p=1103831&amp;postcount=9. | |||
<br />h3. Step 1</s> Find the libraries and download them to your desktop | |||
* Open the xterm on your Nokia N9 | |||
* Type "devel-su&quot; and password "rootme&quot; | |||
* Type "apt-get install libblas3gf&quot;, "apt-get install liblapack&quot; and "apt-get install libgfortran&quot; | |||
Note: you can also download the LAPACK and BLAS (but not GFORTRAN?) libraries onto your desktop<br />http://harmattan-dev.nokia.com/pool/harmattan/free/l/lapack/<br />http://harmattan-dev.nokia.com/pool/harmattan/free/b/blas/ | |||
* Copy these files from /usr/lib on N9 to your "MyDocs&quot; directory then onto your desktop | |||
* Copy these files from /usr/lib on N9 to your | |||
* Move the libraries to your Harmattan libraries area on your desktop (e.g. /opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib) | * Move the libraries to your Harmattan libraries area on your desktop (e.g. /opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib) | ||
===Step 2: Create pkg-config files for each library | === Step 2: Create pkg-config files for each library === | ||
For each library create a ".pc&quot; file to describe its location: | |||
<code># Package Information for pkg-config | |||
prefix=/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/<br />exec_prefix=${prefix}<br />libdir=${exec_prefix}/lib/<br />includedir=${prefix}/include/<br />Name: lapack<br />Description: LAPACK library<br />Version: Unknown<br />Libs: -L${libdir}<br />Cflags: <s>I${includedir}</code> | |||
<br />Save these files to the /usr/lib/pkgconfig directory in your Harmattan area (e.g. <code>/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/lib/pkgconfig<code>) | |||
<br />h3. Step 3</s> Open your project file in Qt Creator | |||
Add the links to the libraries to your ".pro&quot; project file: | |||
</code> CONFIG+=link_pkgconfig<br /> PKGCONFIG+=libblas<br /> PKGCONFIG+=liblapack<br /> PKGCONFIG+=libgfortran<br /><code> | |||
=== Step 4 - Select 'Build'<s>'Run qmake' from within Qt Creator | |||
<br />h3. Step 5</s> Manually edit the Makefile it creates to include references to the LAPACK, BLAS and gfortran libraries === | |||
== | i.e. convert this:<br /></code></code>LIBS = $(SUBLIBS) -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/lib -L/usr/X11R6/lib -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib/lapack/ -L/usr/lib -lQtOpenGL -lQtGui -lQtCore -lGLESv2 -lpthread </code><br /><code> to this:<br /></code>LIBS = $(SUBLIBS) -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/lib -L/usr/X11R6/lib -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib/lapack/ -l:libblas.so -l:liblapack.so -l:libgfortran.so.3 -L/usr/lib -lQtOpenGL -lQtGui -lQtCore -lGLESv2 <s>lpthread<br /><code> | ||
<br />Click the 'Build' button to compile the program as you would usually. | |||
<br />h3. Step 6</s> Run the program on your remote device | |||
The BLAS, LAPACK and gfrotran libraries are already installed from the earlier step. | |||
Revision as of 10:38, 24 February 2015
[toc align_right="yes" depth="3"]
Cross compile a Qt program for Harmattan using the LAPACK library
Summary
"LAPACK":http://www.netlib.org/lapack/#_presentation provides routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems. It is written in Fortran 90.
It is not obvious how to link against LAPACK when cross-compiling a program for use on a Harmattan device as the 'official' method doesn't seem to work as expected.
Workarounds seem to be required both for obtaining the libraries and for cross-compiling the program. An interpretation of the 'official' method, and a workaround method, are included below. This method is based on the method by avieli "here":http://talk.maemo.org/showpost.php?p=1103831&postcount=9.
Method 1: The 'Official' Method
Ideally the Nokia Qt Creator Harmattan SDK would come with LAPACK, BLAS and GFORTRAN libararies as standard. However, this does not appear to be the case. If it were you should then be able to add the following lines of code to your project file:
CONFIG+=link_pkgconfig<br /> PKGCONFIG+=libblas<br /> PKGCONFIG+=liblapack<br /> PKGCONFIG+=libgfortran<br />
QMake would then create a makefile and the libraries would be automatically linked when compilation took place.
At the moment the problems seem to be:
- These libraries are not in the standard Nokia Qt Creator SDK install (with Harmattan options selected) - they have to be downloaded and pkg-config files constructed manually;
- QMake does not seem to correctly construct the makefile with references to these libraries - it only references the directories where these libraries reside (i.e. my makefile did not include the '
l' statements which referenced the specific libraries.)
Find the libraries and download them to your desktop
h2. Method 2: The 'Workaround' Method
This method is based on the method by avieli "here":http://talk.maemo.org/showpost.php?p=1103831&postcount=9.
h3. Step 1
- Open the xterm on your Nokia N9
- Type "devel-su" and password "rootme"
- Type "apt-get install libblas3gf", "apt-get install liblapack" and "apt-get install libgfortran"
Note: you can also download the LAPACK and BLAS (but not GFORTRAN?) libraries onto your desktop
http://harmattan-dev.nokia.com/pool/harmattan/free/l/lapack/
http://harmattan-dev.nokia.com/pool/harmattan/free/b/blas/
- Copy these files from /usr/lib on N9 to your "MyDocs" directory then onto your desktop
- Move the libraries to your Harmattan libraries area on your desktop (e.g. /opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib)
Step 2: Create pkg-config files for each library
For each library create a ".pc" file to describe its location:
# Package Information for pkg-config
prefix=/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/<br />exec_prefix=${prefix}<br />libdir=${exec_prefix}/lib/<br />includedir=${prefix}/include/<br />Name: lapack<br />Description: LAPACK library<br />Version: Unknown<br />Libs: -L${libdir}<br />Cflags: <s>I${includedir}
Save these files to the /usr/lib/pkgconfig directory in your Harmattan area (e.g.
/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/lib/pkgconfig<code>)
<br />h3. Step 3</s> Open your project file in Qt Creator
Add the links to the libraries to your ".pro&quot; project file:
CONFIG+=link_pkgconfig
PKGCONFIG+=libblas
PKGCONFIG+=liblapack
PKGCONFIG+=libgfortran
=== Step 4 - Select 'Build'<s>'Run qmake' from within Qt Creator
<br />h3. Step 5</s> Manually edit the Makefile it creates to include references to the LAPACK, BLAS and gfortran libraries ===
i.e. convert this:<br />
LIBS = $(SUBLIBS) -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/lib -L/usr/X11R6/lib -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib/lapack/ -L/usr/lib -lQtOpenGL -lQtGui -lQtCore -lGLESv2 -lpthread
to this:<br />
LIBS = $(SUBLIBS) -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/lib -L/usr/X11R6/lib -L/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/lib/lapack/ -l:libblas.so -l:liblapack.so -l:libgfortran.so.3 -L/usr/lib -lQtOpenGL -lQtGui -lQtCore -lGLESv2 lpthread
Click the 'Build' button to compile the program as you would usually.
h3. Step 6 Run the program on your remote device
The BLAS, LAPACK and gfrotran libraries are already installed from the earlier step.