[ADMB Users] How to use Autodif as a regular external C++ library?

John Sibert sibert at hawaii.edu
Sat Nov 3 13:17:27 PDT 2012


I generally use make to compile and link AUTODIF applications. Here are 
examples of compiler and linker flags that are used in a linux 
environment. There are some application specific settings so, I  have 
also included simplified versions below the ------------

# make with "optimized" library without subscript checking
CFLAGS= -m64 -DTRUE=true -DFALSE=false -DVERCONS=1 -D__GNUDOS__ 
-DOPT_LIB -fpermissive -Wno-deprecated -I${ADMB_HOME}/include 
-I${JNIGRAPHICS_PATH} -I$(JAVA_HOME)/include 
-I$(JAVA_HOME)/include/linux -I/usr/include/libxml2 $(INCPATH)

LFLAGS= -L${JNIGRAPHICS_PATH} -L$(JAVA_HOME)/jre/lib/amd64/server 
-L${ADMB_HOME}/lib -ljnigraphics3 -ldf1b2o -ladmod -ladt -lado -ldf1b2o 
-ladmod -ladt -lads -lstdc++ -lm -lado -ladt -ldl -ljvm -lxml2 
-L/usr/share/pvm3/lib/LINUX64

# make with safe library for subscript checking
CFLAGS= -m64 -ggdb -DTRUE=true -DFALSE=false -DVERCONS=1 -D__GNUDOS__ 
-fpermissive -Wno-deprecated -I${ADMB_HOME}/include 
-I${JNIGRAPHICS_PATH} -I$(JAVA_HOME)/include 
-I$(JAVA_HOME)/include/linux -I/usr/include/libxml2 $(INCPATH)

LFLAGS= -ggdb -L${JNIGRAPHICS_PATH} -L$(JAVA_HOME)/jre/lib/amd64/server 
-L${ADMB_HOME}/lib -ljnigraphics3 -ldf1b2s -ladmod -ladt -lads -ldf1b2s 
-ladmod -ladt -lads -lstdc++ -lm -lads -ladt -ldl -ljvm -lxml2 
-L/usr/share/pvm3/lib/LINUX64

------------------

#make with "optimized" library without subscript checking
CFLAGS= -D__GNUDOS__ -DOPT_LIB -fpermissive -Wno-deprecated 
-I${ADMB_HOME}/include

LFLAGS= -L${ADMB_HOME}/lib -ldf1b2o -ladmod -ladt -lado -ldf1b2o -ladmod 
-ladt -lads -lstdc++ -lm -lado -ladt

# make with safe library for subscript checking and symbolic debugging
CFLAGS= -ggdb -D__GNUDOS__ -fpermissive -Wno-deprecated 
-I${ADMB_HOME}/include

LFLAGS= -ggdb -L${ADMB_HOME}/lib -ldf1b2s -ladmod -ladt -lads -ldf1b2s 
-ladmod -ladt -lads -lstdc++ -lm -lads

-------------------------

So (at least for this 3 year-old) example, the libraries you need are 
libadmod.a libadt.a libado.a (or libads.a) for the safe libraries. Note 
the order is important and they need to be linked twice (not sure why). 
Also, it appears that some the ADModel Builder libraries (libdf1b2o.a 
and libadmod.a) may be required to satisfy some references. Since these 
librararies are included in the ADMB distributions, there is no real 
downside to linking them into the application anyhow).

Please let us know how you make out.

John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa

Visit the ADMB project http://admb-project.org/

On 11/03/2012 03:46 AM, Pedro Tabacof wrote:
> Hello,
>
> I've been searching for automatic differentiation tools and I found 
> ADMB's Autodif to be quite what I needed. However, I've been having 
> some problems regarding its use from a regular C++ application.
>
> All the step-by-step manuals on the website show how to use the 
> command prompt program "admb" (which tested just fine here), but I 
> wanna use Autodif inside a large C++ project, a little bit like its 
> manual shows, by including headers (in this case fvar.hpp) to the 
> source code and using the corresponding classes for automatic 
> differentiation (such as dvector).
>
> The problem is that the compiler complains (rightly so) that all the 
> classes declared by fvar.hpp are undefined references. There are many 
> libraries that come with ADMB, so how am I supposed to know which ones 
> are required by Autodif classes? Is there any manual or guide that may 
> shine a light on this? Is it even possible to do what I'm attempting 
> to do?
>
> Thanks a lot,
> Pedro Tabacof,
> State University of Campinas, Brazil.
>
>
>
> -- 
> Pedro Tabacof,
> Unicamp - Eng. de Computação 08.
>
>
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users





More information about the Users mailing list