<div dir="ltr">Dear gmsh developers,<div><br></div><div>     I am learning to link gmsh in a c++ code.  I tried with <span style="background-color:rgb(249,249,249)"><font color="#000000"><span style="font-size:12px;line-height:1.1em">Takuya OSHIMA's code to start with.  I was able to link the header files but I </span><span style="font-size:12px;line-height:13px">couldn't</span><span style="font-size:12px;line-height:1.1em"> link the gmsh </span></font></span><font color="#000000"><span style="font-size:12px;line-height:13px">library on a LINUX system from the terminal.</span></font></div>
<div><br></div><div><font color="#000000"><span style="font-size:12px;line-height:13px">The errors that pop up are:</span></font></div><div><font color="#000000"><span style="font-size:12px;line-height:13px"><br></span></font></div>
<div><p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x2e): undefined reference to `GmshInitialize(int, char**)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x9c): undefined reference to `GmshSetOption(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double, int)'</p>

<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x140): undefined reference to `GmshSetOption(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, double, int)'</p>

<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x1b9): undefined reference to `GModel::GModel(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x218): undefined reference to `GModel::setFactory(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'</p>

<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x270): undefined reference to `GModel::addVertex(double, double, double, double)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x2a3): undefined reference to `GModel::addVertex(double, double, double, double)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x2d6): undefined reference to `GModel::addVertex(double, double, double, double)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x309): undefined reference to `GModel::addVertex(double, double, double, double)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x334): undefined reference to `GModel::addVertex(double, double, double, double)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x352): undefined reference to `GModel::addLine(GVertex*, GVertex*)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x373): undefined reference to `GModel::addLine(GVertex*, GVertex*)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x394): undefined reference to `GModel::addLine(GVertex*, GVertex*)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x3b5): undefined reference to `GModel::addLine(GVertex*, GVertex*)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x4db): undefined reference to `GModel::addPlanarFace(std::vector<std::vector<GEdge*, std::allocator<GEdge*> >, std::allocator<std::vector<GEdge*, std::allocator<GEdge*> > > >)'</p>

<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x543): undefined reference to `GModel::writeGEO(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'</p>

<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x572): undefined reference to `GModel::mesh(int)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x5d9): undefined reference to `GModel::writeMSH(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double, bool, bool, bool, double, int, int)'</p>

<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x60d): undefined reference to `GModel::indexMeshVertices(bool, int)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x61c): undefined reference to `GModel::getNumMeshVertices()'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x642): undefined reference to `GModel::getMeshVertexByTag(int)'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">main.cpp:(.text+0x7f9): undefined reference to `GmshFinalize()'</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">collect2: ld returned 1 exit status</p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">This is what I used so far:</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">-l /usr/lib/<a href="http://libgmsh-2.5.1.so">libgmsh-2.5.1.so</a></p><p style="margin:0px;font-size:11px;font-family:Menlo">and</p><p style="margin:0px;font-size:11px;font-family:Menlo">
g++ -o main -L/usr/lib/libgmsh.a main.o</p><p style="margin:0px;font-size:11px;font-family:Menlo">and </p><p style="margin:0px;font-size:11px;font-family:Menlo">gcc -c /usr/lib/<a href="http://libgmsh-2.5.1.so">libgmsh-2.5.1.so</a> main.cpp</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">Still I get the same errors when I compile.</p><p style="margin:0px;font-size:11px;font-family:Menlo"><br>
</p><p style="margin:0px;font-size:11px;font-family:Menlo">Can someone help me to link the libgmsh.a when compiling the .cpp file?</p><p style="margin:0px;font-size:11px;font-family:Menlo">Thanks in advance.</p><p style="margin:0px;font-size:11px;font-family:Menlo">
<br></p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p></div></div>