FileGDBAPI.dll is not compatible with programs using static C runtime library

3200
3
05-21-2013 07:56 AM
DanFoster
New Contributor
I get data corruption and and an assertion in the destructor for wstring parameters passed across the API when I compile the sample programs or my own product using the non-DLL version of the Runtime Library in Visual Studio 2012.

Specifically, if I change the C/C++ Code Generation Runtime Library from Multi-threaded Debug DLL (/MDd) to Multi-threaded Debug (/MTd), the sample program crashes.

My own software uses MFC in a Static Library (not a shared DLL) and therefore requires the non-DLL runtime libraries. Many other APIs come with multiple versions to support multiple runtime options. See an example here:
http://www.smalleranimals.com/isource.htm#download

Please release a version of the DLL compiled for the static C runtime.

Tested with Windows 8, Visual Studio 2012.

Debug Assertion Failed!
Display.exe
File: ..\self_x86\crt\src\dbgheap.c
Line: 1424
Expression: _pFirstBlock == pHead

Here's a snippet of code from the Display sample:

  // Iterate through the results, populating the results vector.
  results.clear();
  Row row;
  PointShapeBuffer geometry;
  Point* point;
  while (enumRows.Next(row) == S_OK)
  {
     wstring cityName;
     row.GetString(L"CITY_NAME", cityName);
...
  }

// get error when cityName's destructor is called
0 Kudos
3 Replies
VinceAngelo
Esri Esteemed Contributor
I prefer to use static libraries as well, but the FGDB API is not released static.  It is released
for VS2008/VS2010/VS2012 on 32-bit/64-bit with Release/Debug (12 different environments).
Adding static/dynamic would make it 24. I just don't see that happening.

- V
0 Kudos
ViksitAgarwal
New Contributor
I also experienced crashes in FileGDB API while destructing wstring when I had my code compiled into a static lib.  But this was happening only when I was testing my static lib code using Visual Studio C++ unit tests.  Everything worked fine when using a console application or a dll linking to static lib.  I thought this is a Microsoft bug in C++ unit test framework and ignored the crash.  After seeing your post, it seems there is some bug in FileGDB C++ API that we see crashes in wstring destruction.
0 Kudos
WillemLigtendag
New Contributor II
Setting the C/C++ Code Generation Runtime Library to Multi-threaded Debug DLL (/MDd) helps in Visual Studio 2012, but when I compiled my code in Visual Studio 2013 Preview and ran it, even that option led to the runtime error mentioned above. So it is probably not only a static linking problem.
0 Kudos