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

Pedro Tabacof tabacof at gmail.com
Sun Nov 4 12:41:43 PST 2012


I'm already trying to integrate Autodif to a large project of mine, but
I've been having some issues:

I'm trying to put some dvariables inside a regular struct, is that possible
to do? After I declare the struct (using malloc), whenever I try to assign
a value to the dvariables, a segfault happens.

What is the correct way to do this?

Thanks,
Pedro.

On Sun, Nov 4, 2012 at 1:12 AM, Pedro Tabacof <tabacof at gmail.com> wrote:

> First of all I must say that never before have I received so much help in
> so little time, this is just unbelievable as a computer engineer :)
>
> I finally managed to compile the first example given in Autodif manual
> following your suggestions. As Dave said, I used the same flags the admb
> console program uses, and as John remarked, I put them in exactly the same
> order.
>
> In the end I was using the correct libraries but in a kinda random order,
> and I was also eliminating duplicates (I wrongly thought they were
> meaningless).
>
> As a reference for future users, I'm using MinGW 32 through Windows 7
> Eclipse and my code is left as an attachment.
>
> Thanks again,
> Pedro.
>
> On Sat, Nov 3, 2012 at 6:17 PM, John Sibert <sibert at hawaii.edu> wrote:
>
>> 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<http://lists.admb-project.org/mailman/listinfo/users>
>>>
>>
>>
>>
>
>
> --
> Pedro Tabacof,
> Unicamp - Eng. de Computação 08.
>
>


-- 
Pedro Tabacof,
Unicamp - Eng. de Computação 08.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20121104/47244804/attachment.html>


More information about the Users mailing list