Linking static and shared libraries in the KDevelop Environment

Daniel Franke franke.daniel at gmail.com
Wed Oct 19 16:05:29 BST 2005


On Wednesday 19 October 2005 16:01, Tristan Robert Martindale wrote:
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

please, don't post HTML-mails ...


> The math library is static(.a). The only way I can get it to link is by
> placing its full path in "Project -> Project options ->; Configure
> Options -> Linker flags (LDFLAGS):". I then include the header files
> by using the Automake Manager and right clicking "src" selecting the
> "Includes" tab and adding the relevant directory to the "Directories
> outside project" pane. This works fine.

... for you. Are you going to distribute your project? If yes, you should not 
use those fields but prefer to supply autoconf macros which add "--enable" or 
"--with" flags to configure -- at least, that my opinion, others may think 
differently. 

A crude (and untested) example to add your math-library:
-- 8< --
AC_ARG_WITH([mathlib-dir], 
            AC_HELP_STRING([--with-mathlib-dir], 
                           [where the math lib resides]),
            [ac_cv_with_mathlib=$withval]) 
AC_CACHE_CHECK([for mathlib], 
               [ac_cv_with_mathlib]) 
 
if test "x$ac_cv_with_mathlib" = "x" ; then 
    AC_ERROR("mathlib not found")
else
    CFLAGS   += -I$mathlib/include
    CXXFLAGS += -I$mathlib/include
    LDFLAGS  += -Lmathlib/lib -lmathlib
fi 
-- 8< --

Add code like this to configure.in (you may define a new macro in acinclude.m4 
and call the macro from configure.in instead), run "Automake & Friends", then 
add "--with-mathlib-dir=<your-path>" to the configure-flags (Project->Project 
Options->Configure Options->Configure arguments).

You have to spent some time to implement and debug these macros, but it's 
worth the effort if other people are going to use your package.


For another example see [1], documentation of AC_* and AM_* macros may be 
found here [2] and here [3] respectively. Btw, don't miss the autoconf macro 
archive [4]!

Good Luck
	Daniel

P.S. Settings->Configure Kdevelop->General->Compiler Output->Full
should solve some of the other mysteries ;)



[1] http://www.kdevelop.org/phorum5/read.php?2,28210,28210#msg-28210
[2] http://www.gnu.org/software/autoconf/manual/index.html
[3] http://sources.redhat.com/automake/automake.html
[4] http://autoconf-archive.cryp.to/macros-by-category.html



-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list