Select to view content in your preferred language

Problems migrating ArcSDE C SDK project to Visual Studio 2008 (Windows 7)

1093
7
04-11-2011 11:10 PM
BarbaraSchneider
Emerging Contributor

Hello,



I am migrating a solution from Visual Studio 2005 (Windows XP, ArcGIS 9.3.1) to Visual Studio 2008 (Windows 7, ArcGIS 10). The solution contains several ArcMap Class libraries (dlls). The libraries are written in C#. One library, however, is written in C++ (named SDEWriter). It is a CLR class library (dll) and uses the ArcSDE C SDK written in native C. I have a problem linking the ArcSDE libraries (libs) to my SDEWriter dll. One of the error messages is as follows:



error LNK2028: unresolved token (0A00000E) "extern "C" long __stdcall SE_error_get_string(long,char *)" (?SE_error_get_string@@$$J18YGJJPAD@Z) referenced in function "public: static bool __clrcall SDEWriter::SDEfuncs::Error(long,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)"



As far as I understand the problem, my C++ project is a managed project, whereas the ArcSDE C SDK libraries are written in native C. --> My managed project (dll) cannot link to the unmanaged ArcSDE libraries (libs). What is strange: on Windows XP, everything worked fine!



Some additional information about the "SDEWriter" project properties:




  • Common Language Runtime Support: Old Syntax (/clr: oldSyntax)

  • Additional Include Directories: path to the ArcSDE C SDK include folder

  • Additional Libary Directories: path to the ArcSDE C SDK lib folder

  • Additional Dependencies: sg.lib, sde.lib, pe.lib and icuuc.lib

I have searched the web and tried out a lot of things, but nothing works! I would be very glad if anyone could help!!!

Thanks a lot for your help in advance,



Barbara

0 Kudos
7 Replies
VinceAngelo
Esri Esteemed Contributor
Your title is a bit misleading, since the issue is VS2005->VS2008 migration.

I've been using  vs9 for several years, but I write 'C' programs with the 'C' API. I found
incompatibility with the default time_t upon upgrade to VS2008, requiring addition of a
_USE_32BIT_TIME_T macro on Win32 projects (x64 ArcSDE uses the default 64-bit
time_t).

The static/dynamic issue seems like an artifact introduced by Microsoft with the new
compiler.  I've found that rebuilding my solution from scratch can sometimes change
dependencies, so if you can't live with a static DLL, then that should probably be your
first step.

- V
0 Kudos
BarbaraSchneider
Emerging Contributor
Hi Vince,

thank you for your reply!
I now understand why I can build a static library (lib): no linking is done there. I can compile my project, but I cannot link it. Rebuilding my solution from scratch doesn't help.

The problem is that the linker cannot find the sde.dll, or that it cannot find the methods in the sde.lib. That's what I infer from the linker outputs:

In my VS 2005 project, the linker output is as follows:
......
1>Searching libraries
1>     Searching C:\ArcGIS\ArcSDE\lib\sde.lib:
1>      Found _SE_error_get_string@8
1>        Loaded sde.lib(sde.dll)
........
In my VS 2008 project, however, the linker output is as follows:
.......
1>Searching libraries
1>    Searching C:\ArcGIS\arcsde\lib\sde.lib:
......
I don't use the data type time_t in my project, so I suppose that this is not a problem? Otherwise, could you please explain to me how this macro works? I haven't found anything useful on the web.

Thanks,

Barbara
0 Kudos
VinceAngelo
Esri Esteemed Contributor
If the linker isn't finding the DLL, it might not be looking for the one that's been installed.
Do you have a 64-bit ArcSDE SDK installed?  ArcGIS 10.1 will be mostly 64-bit, but 10.0
is mostly 32-bit.

Unix has this great little utility called 'ldd' which reports dynamic library dependencies and
resolution for an application or library.  The closest windows has is Dependency Walker,
which I've used to track down obscure dependencies.

If the time_t size was an issue you would have gotten a different error.

- V
0 Kudos
BarbaraSchneider
Emerging Contributor
Hi Vince,

I have 64-bit ArcSDE SDK installed. I am using ArcGIS 10.0.

I have already tried the dependency walker, but it gave me some strange results:

- On my "old" machine (i.e. the one with VS 2005 and ArcGIS 9.3.1), I opened SDEWriter.dll in dependecy walker. There was an error message saying sde.dll and msvcr80d.dll could not be found (see attachment "VS2005_DepWalker_SDEWriter.dll.jpg"). This is REALLY strange because I could build and link my SDEWriter.dll, and the code works!

- On my "new" machine (VS 2008 and ArcGIS 10.0) I could obviously not open SDEWriter.dll in dependecy walker (because it could not be created beforehand). However, I opened sde.dll. There were also some error messages (see attachment "VS2008_DepWalker_Sde.dll.jpg"). I don't know if they are important.

Thanks a lot in advance for your help!

Barbara
0 Kudos
VinceAngelo
Esri Esteemed Contributor
The 64-bit ArcSDE SDK will *NOT* link to 32-bit applications.

This is true on *all* platforms --

32-bit app with 32-bit SDK with 32-bit DLL on 32-bit _OR_ 64-bit OS

or

64-bit app with 64-bit SDK with 64-bit DLL on 64-bit OS *only*

If you uninstall the 64-bit SDK and install the 32-bit, your applications will resolve the
sde.dll/sg.dll/pe.dll dependency chain.

- V
0 Kudos
BarbaraSchneider
Emerging Contributor
Hi Vince,

cool!!!!!!! If this is the solution, I can go on a vacation ...:D

I'll try it tomorrow and let you know.

Have a nice day,
Barbara
0 Kudos
BarbaraSchneider
Emerging Contributor
Hi Vince,

it works!

Thanks a lot for your help,
Barbara
0 Kudos