[gdal-dev] Unable to link gdal : CPLCreateOrAcquireMutex reference not found

Alexandre Herbreteau alexandre.herbreteau at gmail.com
Thu Dec 8 04:57:38 EST 2011


Hi,

I've downloaded the latest GDAL source code by i'm unable to produce a
library. It is due to a link error : "undefined reference to
`CPLCreateOrAcquireMutex"

I'm using Mingw with gcc 4.5.2. Here is what I do :

Unzip, go to Gdal root directory, and run configure:
- This generate a file cpl_config.h (under "port" directory) with this
option :
#define CPL_MULTIPROC_PTHREAD 1

It seems to be very strange because this flag prevents the function
CPLCreateOrAcquireMutex to be declared in the cpl_multiproc.cpp file.
Actually, here is the file structure :

/******* FIRST PART DEFINITION *************/
#ifndef CPL_MULTIPROC_PTHREAD
   int CPLCreateOrAcquireMutex( void **phMutex, double dfWaitInSeconds ) {
.... }
#endif

.....


/******* SECOND PART DEFINITION *************/
#if defined(CPL_MULTIPROC_STUB)
  .....
#elif defined(CPL_MULTIPROC_WIN32)
  ....
#elif defined(CPL_MULTIPROC_PTHREAD)
   int CPLCreateOrAcquireMutex( void **phMutex, double dfWaitInSeconds ) {
...... }
#endif

And CPLCreateOrAcquireMutex is used in CPLMutexHolder (which is not under
precompilation directive, so it is compiled whenever CPL_MULTIPROC_STUB,
CPL_MULTIPROC_WIN32 or CPL_MULTIPROC_PTHREAD are defined or not).

So, defining CPLCreateOrAcquireMutex seems to be absolutly necessary but in
this case it cannot work because both CPL_MULTIPROC_WIN32 and
CPL_MULTIPROC_PTHREAD are defined..... :
- CPL_MULTIPROC_WIN32 is defined in cpl_multiproc.h file :
      #if defined(WIN32) && !defined(CPL_MULTIPROC_STUB)
             #  define CPL_MULTIPROC_WIN32
      #endif
- CPL_MULTIPROC_PTHREAD is defined in cpl_config.h, generated file, as I've
already explained before....

The result :
   1) In the FIRST PART DEFINITION, code int CPLCreateOrAcquireMutex(  ....
is not build due to preprocessing directives,
   2) In the SECOND PART DEFINITION, the code after "#elif
defined(CPL_MULTIPROC_WIN32)" is compiled, and " int
CPLCreateOrAcquireMutex(..." is not build too....
   3) To conclude, this code is not available for the calling function.

It is quite strange that nobody already reported this problem, because
compiling GDAL with CPL_MULTIPROC_PTHREAD support and under WIN32 is
something really usual !!!!

What is wrong, please, with my way of doing ?

Thanks a lot for your answer.

Alexandre.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111208/f80e7862/attachment-0001.html


More information about the gdal-dev mailing list