NGSolve / netgen

https://ngsolve.org
GNU Lesser General Public License v2.1
298 stars 131 forks source link

redefinition of DLL_HEADER #32

Closed reox closed 4 years ago

reox commented 5 years ago

I try to build a version of FreeCAD with netgen enabled for FEM meshing. But it looks like that something does not work and the meshes are broken (OT but if someone has some idea in this direction, please follow the thread in the FC forum: https://forum.freecadweb.org/viewtopic.php?f=4&t=37249)

I saw repeatedly, that there are some warnings in the compiler log, usually like this:

00:29:35 O: In file included from /usr/include/netgen/include/../general/myadt.hpp:17,
00:29:35 O:                  from /usr/include/netgen/include/../meshing/../include/myadt.hpp:1,
00:29:35 O:                  from /usr/include/netgen/include/../meshing/meshing.hpp:6,
00:29:35 O:                  from /usr/include/netgen/include/meshing.hpp:1,
00:29:35 O:                  from /usr/include/netgen/include/../occ/occgeom.hpp:12,
00:29:35 O:                  from /usr/include/netgen/include/occgeom.hpp:1,
00:29:35 O:                  from /build/freecad-daily-0.19+git201907030013~daily/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp:73:
00:29:35 O: /usr/include/netgen/include/../general/../include/mydefs.hpp:26: warning: "DLL_HEADER" redefined
00:29:35 O:        #define DLL_HEADER __attribute__ ((visibility ("default")))
00:29:35 O:
00:29:35 O: In file included from /build/freecad-daily-0.19+git201907030013~daily/src/3rdParty/salomesmesh/inc/NETGENPlugin_Mesher.hxx:42,
00:29:35 O:                  from /build/freecad-daily-0.19+git201907030013~daily/src/3rdParty/salomesmesh/inc/NETGENPlugin_NETGEN_3D.hxx:35,
00:29:35 O:                  from /build/freecad-daily-0.19+git201907030013~daily/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp:31:
00:29:35 O: /usr/include/netgen/nglib.h:33: note: this is the location of the previous definition
00:29:35 O:     #define DLL_HEADER

The problem is, this piece of code: https://github.com/NGSolve/netgen/blob/95efdd212d6bba40349f7352fdc1066acc4b1318/nglib/nglib.h#L24-L34 if nglib.h is used together with some other header which includes mydefs.hpp it will come to this redefintion: https://github.com/NGSolve/netgen/blob/18044b8897131c7372eb75ab9c69d218476187bc/libsrc/include/mydefs.hpp#L18-L30

Now, the bad thing is, both codes are different - the one in mydefs.hpp was changed more recently. I guess there should be some include guard or the DLL_HEADER should be put into a separate header file. There is also nginterface.hpp which defines DLL_HEADER. As far as I can see, the project builds just fine otherwise.

I also do not fully understand the structure of the header files. At least on debian, there are several files duplicated: https://packages.debian.org/sid/amd64/netgen-headers/filelist For example /usr/include/netgen/include/{mydefs.hpp,nginterface.h} are the same as /usr/include/netgen/{mydefs.hpp,nginterface.h}. Other files in the /usr/include/netgen/include folder simply include just one file with the same name in another subfolder of /usr/include/netgen/, others define own stuff. Is all this duplication necessary or just backwards compatability?

Thanks in advance!

mhochsteger commented 4 years ago

Thanks for the report, this is fixed in the current master branch.