user's code compilation and link against the hermes2d library

24 views
Skip to first unread message

Valmor de Almeida

unread,
Jul 3, 2013, 11:53:19 PM7/3/13
to herm...@googlegroups.com
Hello,

I have a legacy herms2d code I would like to get updated. In the past
I built the code inside the examples/ directory. This entailed
modification of the cmake files to compile and link the code in, say,
examples/mycode/.
Is this still the way to build code with hermes2d? or is there another
way where hermes2d can stay inside a directory, say /opt/hermes2d and
a user's code could be in /home/john/fem/myapplication/ . If so, is
there a documentation on how to compile and link against the hermes2d
library?

Thanks,

--
Valmor

Lukas Korous

unread,
Jul 4, 2013, 3:42:18 AM7/4/13
to herm...@googlegroups.com
Hello Valmor,

there is a way to do it, in fact that is how we do it ourselves now
(we use different repositories - hermes_examples, hermes_tutorial - in
different locations) and we only use CMake to link against hermes2d.

But basically it is just as with any other library.
You compile and install Hermes (by running sudo make install), and it
installs hermes to standard locations (unless you changed the
CMake.vars variable "TARGET_ROOT" while compiling Hermes) - so to
/usr/local/lib, /usr/local/include.

And then you in your code include the location for the header files of
hermes (in /usr/local/include) - including "hermes2d.h" is enough and
you link against the library with -L /usr/local/lib.

Also, if you want to employ CMake to do the work for you, take a look
at how it is done with the repositories hermes_examples,
hermes_tutorial.

Look at the following (to be found in CMakeLists.txt, and the "cmake"
folder in the root):

CMakeLists.txt:
....
# Where to look for the static libraries.
set(HERMES_DIRECTORY /usr/local/lib)
set(HERMES_INCLUDE_PATH /usr/local/include)
...
set(HERMES2D_INCLUDE_PATH ${HERMES_INCLUDE_PATH}/hermes2d)
set(HERMES_COMMON_INCLUDE_PATH ${HERMES_INCLUDE_PATH}/hermes_common)
find_package(HERMES_COMMON REQUIRED)
include_directories(${HERMES_COMMON_INCLUDE_PATH})
include_directories(${HERMES2D_INCLUDE_PATH})
...

And then files:

\hermes-examples\cmake\CommonTargetProperties.cmake
\hermes-examples\cmake\FindHERMES.cmake
\hermes-examples\cmake\FindHERMES_COMMON.cmake

Looking for the libraries and linking to them.

If you need to navigate more directly, I will probably write some
short tutorial how to do that.
Best Regards,
Lukas
> --
> You received this message because you are subscribed to the Google Groups "hermes2d" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hermes2d+u...@googlegroups.com.
> To post to this group, send email to herm...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hermes2d.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Lukáš Korous
Reply all
Reply to author
Forward
0 new messages