SCI Seg3D Mailing List

Text archives Help


[Seg3D] Re: adding an external library to Seg3D


Chronological Thread 
  • From: Kristen Zygmunt <krismz@sci.utah.edu>
  • To: seg3d@sci.utah.edu
  • Subject: [Seg3D] Re: adding an external library to Seg3D
  • Date: Fri, 16 Oct 2009 12:56:17 -0600


On Oct 16, 2009, at 11:31 AM, Ramón Casero Cañas wrote:


Hi,

I would like to use function QwtSpline() from the C++ library Qwt [1] to
compute a spline for the tool I'm working on.

This library can be configured, compiled and installed with qmake.
Following the way things seem to be done in Seg3D now, I have downloaded
the source code to SCIRun/src/Externals/qwt-5.2 (instead of installing
the ubuntu package)

$ svn export https://qwt.svn.sourceforge.net/svnroot/qwt/branches/qwt-5.2

Could somebody help me with some guidance about how to integrate this new library into the building system of Seg3D, please?

I suppose ideally one would modify the existing CMakeLists.txt and create a new one in qwt-5.2 to build Qwt with the rest of the application, but for the moment I'd be happy building Qwt manually with qmake, and then just linking to the resulting shared library 

SCIRun/src/Externals/qwt-5.2/lib/libqwt.so.5.2.1

I'll give you some suggestions for using CMake, since your situation is a little different from the standard library used by Seg3D since CMake will not actually be building the library.  This will make things easier, but you won't be able to exactly follow existing Seg3D/SCIRun examples.  Also, my command suggestions below are shorthand, I recommend looking at http://cmake.org/cmake/help/cmake-2-8-docs.html for detailed syntax. 

The basic idea is that to link with the resulting shared library, CMake will need to know both the location of the Qwt include files, and the location of the Qwt library.

I would put a basic CMakeLists.txt in the qwt externals directory to define some variables and to install the qwt library into the appropriate location so that it can be found at run time.  Add a line to Externals/CMakeLists.txt to add the qwt subdirectory so that the new CMakeLists.txt is found and included.

if you make a variable say QWT_DIR that points to the top level area say SCIRun/src/Externals/qwt-5.2
then you can create a QWT_INCLUDES variable that points to the relative locations of the include directories, maybe something like ${QWT_DIR}/include (or whatever it happens to be for Qwt)

or you can do a FIND_PATH similar to the FIND_LIBRARY below

Do something similar for the libraries by setting a variable like QWT_LIBRARY to point to ${QWT_DIR}/lib/libqt2.so.5.2.1
Perhaps by using a statement like 
FIND_LIBRARY(QWT_LIBRARY  qt2 PATHS ${QWT_DIR}/lib)

Note:  I think the recommended CMake way to do the above is to actually create a FindQWT.cmake module, but this seems like overkill.  However, there may be one that already exists somewhere.  If so, theoretically you could do a FIND_PACKAGE(QWT) then instead of the above.

Also add some sort of install statement like 
INSTALL(TARGETS ${QWT_LIBRARY}
   RUNTIME DESTINATION bin
   LIBRARY DESTINATION lib
   ARCHIVE DESTINATION lib)

Then add ${QWT_INCLUDES} to SCIRun/src/CMakeLists.txt as part of the INCLUDE_DIRECTORIES statement 

Then in SCIRun/src/Applications/Seg3D/CMakeLists.txt, add a statement like 
TARGET_LINK_LIBRARIES(Seg3D ${QWT_LIBRARY})

Hopefully I haven't missed anything, but I'm not good enough with CMake yet to get it right without testing.  (If anyone out here finds an egregious error with my approach, please let me know so that I can improve my own CMake knowledge.  I don't want to lead anyone to far astray).  This should at least get you started.

As an additional note, I just wanted to let you know I've been following your progress and greatly appreciate your comments / suggestions / documentation.  
Thank you for help,
Kris 








Archive powered by MHonArc 2.6.16.

Top of page