← Back to team overview

dolfin team mailing list archive

Problems linking with dolfin.h

 

In the dev version of dolfin there seems to be a problem with
include/dolfin/assemble.h.  It defines both implementation and
prototype which causes a collision in the namespace, for example take
a foobar library that just imports dolfin.h twice:


aterrel@localhost$ cat foo.cpp
#include <dolfin.h>

aterrel@localhost$ cat bar.cpp
#include <dolfin.h>

aterrel@localhost$ `pkg-config --variable=compiler dolfin` -o foo.os
-c -fPIC `pkg-config --cflags dolfin` foo.cpp
aterrel@localhost$ `pkg-config --variable=compiler dolfin` -o bar.os
-c -fPIC `pkg-config --cflags dolfin` bar.cpp
aterrel@localhost$ `pkg-config --variable=compiler dolfin` -o
foobar.dylib -dynamiclib `pkg-config --cflags --libs dolfin` foo.os
bar.os

ld: multiple definitions of symbol
__ZN6dolfin15assemble_systemERNS_13GenericMatrixERNS_13GenericVectorERKNS_4FormES6_RKNS_11DirichletBCEb
foo.os definition of
__ZN6dolfin15assemble_systemERNS_13GenericMatrixERNS_13GenericVectorERKNS_4FormES6_RKNS_11DirichletBCEb
in section (__TEXT,__text)
bar.os definition of
__ZN6dolfin15assemble_systemERNS_13GenericMatrixERNS_13GenericVectorERKNS_4FormES6_RKNS_11DirichletBCEb
in section (__TEXT,__text)
... lots of functions multiply defined from assemble.h


Removing assemble.h from the top-level include works well, for my
needs I just link it in manually.  To make the library a bit nicer to
use I would suggest splitting the implementation from the prototypes.

-- Andy


Follow ups