[Gmsh] Add gmsh in existing cmake project

Bruno Correia da Silva bcs2 at cin.ufpe.br
Wed Jan 23 21:20:54 CET 2013


Hello Martin,

 Thanks for your attention and support.
 The include error  was my mistake in exploring the code.
 The conflict with FMDB and GMSH is present. Now i am trying to use
namespace to isolated the problem changing the code of GMSH. When happen
some good news i'll return here.

 I think the better question to the Forum is: Someone used in same project
FMDB and GMSH? Using API, and not system call?

Best regards,
Bruno Correia



Hi Bruno,

 check two things:
 1) iofwd.h, line 25: make sure that whatever you put there has this form:
     #include "my_file.h" // The # at the beginning is important.
  and not
     include "my_file.h" or include<my_file.h>

  Use < > for STL headers.

 2) if iofwd is a header created by you, make sure you used include guards.
The first two lines and the last line of your file should say something like
  #ifndef IOFWD_H   // first line
  #define IOFWD_H  // second line

   ... your code ....

 #endif // last line of the file.

 Best regards,

   Martin Vymazal


2013/1/17 Bruno Correia da Silva <bcs2 at cin.ufpe.br>

> Hey Martin,
>
>  Thanks for your support.
>  I did what you explained about add "MEdge.h" and "MFace.h". After this, i
> change again my CMAKELIST.txt.
>  I'm using UNIX makefile compiler and default native compilers.
>  For better explained: I'm using the FMDB library.
>
> My CMAKELIST now is:
> "
> *set (APPLICATIONS /home/padmec/applications)
>  ## FMDB
> set (FMDB_INCLUDE "${APPLICATIONS}/FMDB-2011/**include" CACHE PATH
> "Directory where FMDB header files can be found")
> set (FMDB_LIB "${APPLICATIONS}/FMDB-2011/**lib" CACHE PATH "Directory
> where the FMDB library can be found")
> include_directories(${FMDB_**INCLUDE})
> link_directories(${FMDB_LIB})
> link_libraries(FMDB-O)
>
> #GMSH
> SET( GMSH_SRC "/home/padmec/Desktop/gmsh/**gmsh" CACHE STRING "GMSH SRC" )
> SET( GMSH_INC
>     "${GMSH_SRC}/Common"
>     "${GMSH_SRC}/Geo"
>     "${GMSH_SRC}/Plugin"
>     "${GMSH_SRC}/Solver"
>     "${GMSH_SRC}/Numeric"
>     "${GMSH_SRC}/build/Common" )
> INCLUDE_DIRECTORIES( ${GMSH_INC} )
>
> SET( GMSH_LIB "${GMSH_SRC}/lib" )
>
> add_executable(Remeshing__Proj ${SRCS} ${HDRS})
> TARGET_LINK_LIBRARIES(Remeshing__Proj Gmsh )
> *"
> And show me this errors:
> "*
> /home/padmec/applications/FMDB-2011/include/iofwd.h: At global scope:
> /home/padmec/applications/FMDB-2011/include/iofwd.h:25:1: error: ‘include’
> does not name a type
> In file included from
> /home/padmec/Desktop/gmsh/gmsh/Numeric/Numeric.h:12:0,
>                  from /home/padmec/Desktop/gmsh/gmsh/Geo/GFace.h:19,
>                  from /home/padmec/Desktop/gmsh/gmsh/Geo/GModel.h:16,
>                  from
> /home/padmec/Downloads/Remeshing__project/src/Remover.cpp:10:
> /home/padmec/applications/FMDB-2011/include/SPoint3.h: In function
> ‘SPoint3 operator+(const SPoint3&, const SPoint3&)’:
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:85:16: error:
> redefinition of ‘SPoint3 operator+(const SPoint3&, const SPoint3&)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:49:16: error: ‘SPoint3
> operator+(const SPoint3&, const SPoint3&)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h: In function
> ‘SPoint3 operator-(const SPoint3&, const SPoint3&)’:
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:88:16: error:
> redefinition of ‘SPoint3 operator-(const SPoint3&, const SPoint3&)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:52:16: error: ‘SPoint3
> operator-(const SPoint3&, const SPoint3&)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h: At global scope:
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:91:13: error:
> redefinition of ‘void SPoint3::setPosition(double, double, double)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:55:13: error: ‘void
> SPoint3::setPosition(double, double, double)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:94:13: error:
> redefinition of ‘void SPoint3::getPosition(double*, double*, double*) const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:58:13: error: ‘void
> SPoint3::getPosition(double*, double*, double*) const’ previously defined
> here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:97:13: error:
> redefinition of ‘void SPoint3::position(double*) const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:61:13: error: ‘void
> SPoint3::position(double*) const’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:100:15: error:
> redefinition of ‘double SPoint3::x() const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:64:15: error: ‘double
> SPoint3::x() const’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:103:15: error:
> redefinition of ‘double SPoint3::y() const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:67:15: error: ‘double
> SPoint3::y() const’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:106:15: error:
> redefinition of ‘double SPoint3::z() const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:70:15: error: ‘double
> SPoint3::z() const’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:109:18: error:
> redefinition of ‘SPoint3& SPoint3::operator=(const SPoint3&)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:73:18: error: ‘SPoint3&
> SPoint3::operator=(const SPoint3&)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:112:13: error:
> redefinition of ‘void SPoint3::operator+=(const SPoint3&)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:76:13: error: ‘void
> SPoint3::operator+=(const SPoint3&)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:115:13: error:
> redefinition of ‘void SPoint3::operator-=(const SPoint3&)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:79:13: error: ‘void
> SPoint3::operator-=(const SPoint3&)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:118:13: error:
> redefinition of ‘void SPoint3::operator*=(double)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:82:13: error: ‘void
> SPoint3::operator*=(double)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:121:16: error:
> redefinition of ‘SPoint3 SPoint3::operator*(double)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:88:16: error: ‘SPoint3
> SPoint3::operator*(double)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:124:16: error:
> redefinition of ‘double& SPoint3::operator[](int)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SPoint3.h:91:16: error: ‘double&
> SPoint3::operator[](int)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SPoint3.h:127:15: error:
> redefinition of ‘double SPoint3::operator[](int) const’
> ....
> In file included from
> /home/padmec/Desktop/gmsh/gmsh/Numeric/Numeric.h:13:0,
>                  from /home/padmec/Desktop/gmsh/gmsh/Geo/GFace.h:19,
>                  from /home/padmec/Desktop/gmsh/gmsh/Geo/GModel.h:16,
>                  from
> /home/padmec/Downloads/Remeshing__project/src/Remover.cpp:10:
> /home/padmec/applications/FMDB-2011/include/SVector3.h:27:7: error:
> redefinition of ‘class SVector3’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SVector3.h:15:7: error: previous
> definition of ‘class SVector3’
> /home/padmec/applications/FMDB-2011/include/SVector3.h:96:16: error:
> redefinition of ‘double& SVector3::operator[](int)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SVector3.h:40:11: error: ‘double&
> SVector3::operator[](int)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SVector3.h:99:15: error:
> redefinition of ‘double SVector3::operator[](int) const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SVector3.h:41:10: error: ‘double
> SVector3::operator[](int) const’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SVector3.h:102:16: error:
> redefinition of ‘double& SVector3::operator()(int)’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SVector3.h:42:11: error: ‘double&
> SVector3::operator()(int)’ previously defined here
> /home/padmec/applications/FMDB-2011/include/SVector3.h:105:15: error:
> redefinition of ‘double SVector3::operator()(int) const’
> /home/padmec/Desktop/gmsh/gmsh/Geo/SVector3.h:43:10: error: ‘double
> SVector3::operator()(int) const’ previously defined here*
> "
> Anyone used FMDB and GMSH in a same project? Anyone saw similar errors?
>
> Thanks,
> Best Regards
> Bruno Correia
>
> --------------------
>
> Hi Bruno,
>
>  try to add
>
>  #include "MEdge.h"
>  #include "MFace.h"
>
>  at the beginning of your code to remove the errors you see. I'm not a cmake
> expert either, but I think that the recommended practice is to use
> target_link_libraries(TARGET_NAME lib1 lib2 ...) and not link_directories.
>
> Best regards,
>
>    Martin Vymazal
>
>
>
> 2013/1/3 Bruno Correia da Silva <bcs2 at cin.ufpe.br>
>
>> Sorry,
>>
>>  I'm using ubuntu 12.04.
>>
>> att.
>> Bruno Correia
>>
>> 2013/1/3 Bruno Correia da Silva <bcs2 at cin.ufpe.br>:
>> >  Hey guys,
>> >
>> >   I'm newbie in CMake and linux and i'm still have problems to put
>> > gmsh in my project to make a call from source code.
>> >
>> >   When I add this line in my in my root project path, in file
>> CMakeLists.txt:
>> > "
>> > #GMSH
>> > SET (GMSH_LIB_PATH "/home/padmec/gmsh/lib")
>> > link_directories(${GMSH_LIB_PATH})
>> > link_libraries(Gmsh)
>> > SET (GMSH_INCLUDE_PATH "/home/padmec/gmsh/include/gmsh")
>> > include_directories(${GMSH_INCLUDE_PATH})
>> > "
>> >
>> > And when i only add this lines in my cpp file:
>> > "
>> > #include "Gmsh.h"
>> > #include "GModel.h"
>> > #include "MElement.h"
>> > #include "MVertex.h"
>> > #include <iostream>
>> >
>> > "
>> > Show me this error.
>> > "
>> >
>> > In file included from
>> > /home/padmec/Downloads/Remeshing__project/src/Remover.cpp:11:0:
>> > /home/padmec/gmsh/include/gmsh/MElement.h: At global scope:
>> > /home/padmec/gmsh/include/gmsh/MElement.h:123:11: error: ‘MEdge’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:126:34: error: ‘MEdge’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:126:42: error: ISO C
>> > forbids declaration of ‘edge’ with no type [-fpermissive]
>> > /home/padmec/gmsh/include/gmsh/MElement.h:143:11: error: ‘MFace’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:146:34: error: ‘MFace’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:146:42: error: ISO C
>> > forbids declaration of ‘face’ with no type [-fpermissive]
>> > /home/padmec/gmsh/include/gmsh/MElement.h:364:11: error: ‘MEdge’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:369:10: error: ‘MEdge’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:382:11: error: ‘MFace’ does
>> > not name a type
>> > /home/padmec/gmsh/include/gmsh/MElement.h:387:10: error: ‘MFace’ does
>> > not name a type
>> > make[2]: Leaving directory `/home/padmec/Downloads/Remeshing__project'
>> >
>> > "
>> > Let's go to the asking:
>> > First, someone saw this error before?
>> > Second,  someplace has a explicit way to add gmsh in a project using
>> CMake?
>> > I saw tutorial folders in gmsh source code, but doesn't help so much.
>> >
>> > Best regards
>> > att.
>> > Bruno Correia
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20130123/343f2061/attachment.html>