[Gmsh] gmsh use as DLL

kim nielsen martinez kimepa11 at gmail.com
Wed Sep 25 17:12:37 CEST 2013


Dear gmsh team,

First of all, I would like to congratulate your very nice job. You have
made a very useful and powerful tool, and I would like to thank you for
sharing it with all of us.

I am a little stuck with your program. I would like to be able to compile
your gmsh as a DLL, for later use in a windows application. I am just
interested in using some of the methods of your software for meshing a
geometry, because I would use a personal solver to actually resolve the
FEM. For that reason, I´m not interested in using the FLTK interface. So I
downloaded the source code of gmsh (2.8.2), and with the help of CMake I
unchecked FLTK and checked the DLL and LIB options. Once I had it
configured, I opened it with Visual Studio 2008 and tried to compile it.
Though it gave me some errors, I actually was able to obtain the files I
wanted.

The problem comes when I try to import these LIB or DLL in another MAIN
project I added to the solution. I´ve added the source code to predefined
directories, added the references and even linked the library gmshd.lib
(Linker-<input-additional dependencies). So to see if it works I copied the
code of MainSimple.cpp (contained in utils/appi_demos). When trying to
compile it gives to me the famous linking error LNK2019.
So after trying everything already posted in forums regarding that errors,
I have few questions:
- I didn´t find any .DEF file. I didn´t see in any header nor cpp file the
"extern 'C'" or the "_declspec(dllexport)" directive anywhere, so I´m not
sure if the DLL is done correctly. Does CMake already prepares this?
-By the way, shouldn´t I obtain a LIB file (export library) as well as the
DLL in order to link it to the new project? If not, how can I use it in my
program?
- Did I make any mistake at compiling with CMake? (I´ve never used CMake
and it took me a while to understand how it works, what does it do and how
to configure it).
-I am not able to add directly the DLL as a reference, it gives me many
errors (as it is in machine language already compiled I doubt if VS
understands it) and furthermore it says it can´t find the gmsh.lib
(actually it just creates the gmsh.dll but I´m missing the exporting LIB
file. The correct way would be adding the LIB file which is related to the
DLL instead of adding the DLL itself, am I right? How would I do it without
the DLL?

I would like to use the libraries cause, if possible, I would like to pass
directly from my application a string with all the content of the GEO file
to gmsh, then mesh it and receive back the MSH file but in a string form. I
know that I must adapt some of the source code of gmsh before doing this,
but the first thing I would need to do is being able to use gmsh methods in
another project.

Any help you could provide would be very appreciated. Thank you very much
in advance.

Regards,

Kim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20130925/cd7b3285/attachment.html>