title: G++ create a share library which depends on GDAL
body: <p>I follow this tutorial: <a href="https://www.baeldung.com/jni" rel="nofollow noreferrer">https://www.baeldung.com/jni</a> and I am trying to also use GDAL.
  This is the cpp file:</p>
  <pre><code>#include &lt;jni.h&gt;
  #include &lt;gdal.h&gt;
  #include &lt;ogr_geometry.h&gt;
  #include &lt;util_gdal_GDAL.h&gt;
  
  JNIEXPORT jdoubleArray JNICALL Java_util_gdal_GDAL_CurveToLinestringPoints
  (JNIEnv* env, jobject, jdouble x0, jdouble y0, jdouble z0, jdouble x1, 
      jdouble y1, jdouble z1, jdouble x2, jdouble y2, jdouble z2, jint bHasZ, 
      jdouble dfMaxAngleStepSizeDegrees, jstring papszOptions)
  {
      const char* const papszOptionsCharPointer = env-&gt;GetStringUTFChars(papszOptions, NULL);
      OGRLineString* lineString = OGRGeometryFactory::curveToLineString(x0, y0, z0, x1,
          y1, z1, x2, y2, z2, bHasZ,
          dfMaxAngleStepSizeDegrees, &amp;papszOptionsCharPointer);
  
      int sizeOfLineString = lineString-&gt;getNumPoints();
      //to do
      //const int sizeOfTheArray = bHasZ == 1 ? sizeOfLineString * 3 : sizeOfLineString * 2;
      double listOfCoordintes[20];
  
      int j = 0;
      for (int i = 1; i &lt; lineString-&gt;getNumPoints(); i++)
      {
          listOfCoordintes[j] = lineString-&gt;getX(i);
          listOfCoordintes[++j] = lineString-&gt;getY(i);
          if (bHasZ) {
              listOfCoordintes[++j] = lineString-&gt;getZ(i);
          }
          j++;
      }
  
      jdoubleArray returnArray = env-&gt;NewDoubleArray(4);
      env-&gt;SetDoubleArrayRegion(returnArray, 0, 20, listOfCoordintes);
      return returnArray;
  }
  </code></pre>
  <p>this is the header:</p>
  <pre><code>/* DO NOT EDIT THIS FILE - it is machine generated */
  #include &lt;jni.h&gt;
  /* Header for class util_gdal_GDAL */
  
  #ifndef _Included_util_gdal_GDAL
  #define _Included_util_gdal_GDAL
  #ifdef __cplusplus
  extern &quot;C&quot; {
  #endif
      /*
       * Class:     util_gdal_GDAL
       * Method:    CurveToLinestringPoints
       * Signature: (DDDDDDDDDIDLjava/lang/String;)[D
       */
      JNIEXPORT jdoubleArray JNICALL Java_util_gdal_GDAL_CurveToLinestringPoints
      (JNIEnv*, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jint, jdouble, jstring);
  
  #ifdef __cplusplus
  }
  #endif
  #endif
  </code></pre>
  <p>I used the follow command to compile:</p>
  <pre><code>g++ -c -I&quot;%JAVA_HOME%&quot;\include -I&quot;%JAVA_HOME%&quot;\include\win32 -I. -IC:\Users\Daniela\Projects\gdal-3.5.1\ogr  -IC:\Users\Daniela\Projects\gdal-3.5.1\port -IC:\Users\Daniela\Projects\gdal-3.5.1\apps -IC:\Users\Daniela\Projects\gdal-3.5.1\gcore -IC:\Users\Daniela\Projects\gdal-3.5.1 util_gdal_GDAL.cpp -o util_gdal_GDAL.o
  </code></pre>
  <p>And then I am trying to create the share library:</p>
  <pre><code>g++ -shared -o gdalTest.dll util_gdal_GDAL.o C:\Users\Daniela\Projects\gdal-3.5.1\gdal305_d.dll
  C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: util_gdal_GDAL.o:util_gdal_GDAL.cpp:(.text+0xe0): undefined reference to `OGRGeometryFactory::curveToLineString(double, double, double, double, double, double, double, double, double, int, double, char const* const*)'
  C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: util_gdal_GDAL.o:util_gdal_GDAL.cpp:(.text+0x1ca): undefined reference to `OGRSimpleCurve::getZ(int) const'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  <p>Can you help me to solve these error please?
  Thank you</p>