Cross compile with LAPACK library on Nokia N9: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(nominated for deletion)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Cross compile a Qt program for Harmattan using the <span class="caps">LAPACK</span> library=
{{delete|reason=Obsolete information.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}


==Summary==
= Cross compile a Qt program for Harmattan using the LAPACK library =


[http://www.netlib.org/lapack/#_presentation <span class="caps">LAPACK</span>] ''[netlib.org]'' 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.
== Summary ==


It is not obvious how to link against <span class="caps">LAPACK</span> when cross-compiling a program for use on a Harmattan device as the ‘official’ method doesn’t seem to work as expected.
[http://www.netlib.org/lapack/#_presentation LAPACK] 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.


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 [http://talk.maemo.org/showpost.php?p=1103831&postcount=9 here] ''[talk.maemo.org]''.
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.


==Method 1: The ‘Official’ Method==
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 [http://talk.maemo.org/showpost.php?p=1103831&postcount=9 here].


Ideally the Nokia Qt Creator Harmattan <span class="caps">SDK</span> would come with <span class="caps">LAPACK</span>, <span class="caps">BLAS</span> and <span class="caps">GFORTRAN</span> 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:
== 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
PKGCONFIG+=libblas
PKGCONFIG+=liblapack
PKGCONFIG+=libgfortran
</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 26:
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 <span class="caps">SDK</span> install (with Harmattan options selected) they have to be downloaded and pkg-config files constructed manually;
# 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.)
# 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.)
 
==Method 2: The ‘Workaround’ Method==
 
This method is based on the method by avieli [http://talk.maemo.org/showpost.php?p=1103831&postcount=9 here] ''[talk.maemo.org]''.


===Step 1 – Find the libraries and download them to your desktop===
== Method 2: The 'Workaround' Method ==
This method is based on the method by avieli [http://talk.maemo.org/showpost.php?p=1103831&postcount=9 here].


* Open the xterm on your Nokia N9
=== Step 1- Find the libraries and download them to your desktop ===
* Type “devel-su” and password “rootme”
* Open the xterm on your Nokia N9  
* Type “apt-get install libblas3gf”, “apt-get install liblapack” and “apt-get install libgfortran”
* 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 <span class="caps">LAPACK</span> and <span class="caps">BLAS</span> (but not <span class="caps">GFORTRAN</span>?) 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/
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
* 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)
* 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” file to describe its location:
 
===Step 3 – Open your project file in Qt Creator===


Add the links to the libraries to your “.pro” project file:
For each library create a ".pc" file to describe its location:


===Step 4 – Select ‘Build’-‘Run qmake’ from within Qt Creator===
<code># Package Information for pkg-config


===Step 5 – Manually edit the Makefile it creates to include references to the <span class="caps">LAPACK</span>, <span class="caps">BLAS</span> and gfortran libraries===
prefix=/opt/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/
exec_prefix=${prefix}
libdir=${exec_prefix}/lib/
includedir=${prefix}/include/
Name: lapack
Description: LAPACK library
Version: Unknown
Libs: -L${libdir}
Cflags: -I${includedir}</code>


i.e. convert this:<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@)


Click the ‘Build’ button to compile the program as you would usually.
=== Step 3- Open your project file in Qt Creator ===
Add the links to the libraries to your ".pro" project file:


===Step 6 – Run the program on your remote device===
</code> CONFIG+=link_pkgconfig
PKGCONFIG+=libblas
PKGCONFIG+=liblapack
PKGCONFIG+=libgfortran
<code>


The <span class="caps">BLAS</span>, <span class="caps">LAPACK</span> and gfrotran libraries are already installed from the earlier step.
=== Step 4 - Select 'Build'-'Run qmake' from within Qt Creator


If anyone can update this with a “How to define dependencies for a fresh install on a Harmattan device” it would be much appreciated!
=== Step 5- Manually edit the Makefile it creates to include references to the LAPACK, BLAS and gfortran libraries === ===
i.e. convert this:
</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>
<code> to this:
</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 -lpthread
<code>


===Categories:===
Click the 'Build' button to compile the program as you would usually.


* [[:Category:Developing with Qt|Developing_with_Qt]]
=== Step 6- Run the program on your remote device ===
** [[:Category:Developing with Qt::Harmattan|Harmattan]]
The BLAS, LAPACK and gfrotran libraries are already installed from the earlier step.
* [[:Category:Developing with Qt::Workarounds|Workarounds]]

Latest revision as of 23:54, 24 May 2015

This article is nominated for deletion. Reason: Obsolete information.
Please raise your support/opposition to this nomination in the article's discussion page.
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

Cross compile a Qt program for Harmattan using the LAPACK library

Summary

LAPACK 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.

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
 PKGCONFIG+=libblas
 PKGCONFIG+=liblapack
 PKGCONFIG+=libgfortran

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:

  1. 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;
  2. 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.)

Method 2: The 'Workaround' Method

This method is based on the method by avieli here.

Step 1- Find the libraries and download them to your desktop

  • 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/
exec_prefix=${prefix}
libdir=${exec_prefix}/lib/
includedir=${prefix}/include/
Name: lapack
Description: LAPACK library
Version: Unknown
Libs: -L${libdir}
Cflags: -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@)

=== Step 3- Open your project file in Qt Creator ===
Add the links to the libraries to your ".pro" project file:

CONFIG+=link_pkgconfig

PKGCONFIG+=libblas
PKGCONFIG+=liblapack
PKGCONFIG+=libgfortran
=== Step 4 - Select 'Build'-'Run qmake' from within Qt Creator

=== Step 5- Manually edit the Makefile it creates to include references to the LAPACK, BLAS and gfortran libraries === ===
i.e. convert this:

@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:

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.

Step 6- Run the program on your remote device

The BLAS, LAPACK and gfrotran libraries are already installed from the earlier step.