[mapserver-users] VisualC++ Experts..

Jamie Smedsmo jsmedsmo at gis.umn.edu
Thu May 17 14:51:57 EDT 2001


Here's an answer posted a while ago from Egon Kuster.

UNRESOLVED SYMBOL ERRORS WHEN COMPILING MAPSERVER WITH SDE SUPPORT ON
WIN32

THE PROBLEM:
When compiling mapserver with SDE support in win32 the libraries
provided by
ESRI are not compatible with Microsoft Visual C++ as the symbol names in
the
ESRI SDE do not match the symbol names that mapserver needs when linking
the
project. When linking a C++ program together all the symbol names must
match. When linking the mapserver project it is looking for symbol names
like "_SE_connection_free" or "_SE_error_get_string" but can not find
them.
If you look through the SDE libraries you can easily find these symbols,
so
why doesn't it link?. Well the answer is simple, when Visual C++ creates
the
library file it strips the preceding "_" and following "@xxx" when it
places
the symbol name into the libraries export table. Therefore the name in
the
export table is "SE_connection_free" instead of "_SE_connection_free".
The
means that the symbol names are not matching and the linker can not find
the
correct symbols and produces the following errors when linking:

mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_connection_free
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_free
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_free
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_clip
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_is_nil
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_fetch
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_execute
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_describe_column
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_bind_output_column
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_set_spatial_constraints
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_query
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_sql_construct_alloc
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_generate_rectangle
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layerinfo_get_envelope
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layerinfo_get_coordref
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_coordref_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layer_get_info
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layerinfo_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_connection_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_error_get_string
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_all_points
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_num_points
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_type
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_num_parts
mapserv.exe : fatal error LNK1120: 26 unresolved externals
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

THE SOLUTION:
There is a solution to this problem and it is to creating a DEF file for
the
SDE library. In the DEF file, include an EXPORTS section that contains
the
names of the functions to be included in the library.

Contents of SDE80.DEF:

EXPORTS
  SE_connection_free =_SE_connection_free
  SE_shape_free = _SE_shape_free
  SE_stream_free = _SE_stream_free
  SE_shape_clip = _SE_shape_clip
  SE_shape_is_nil = _SE_shape_is_nil
  SE_stream_fetch = _SE_stream_fetch
  SE_stream_execute = _SE_stream_execute
  SE_stream_describe_column = _SE_stream_describe_column
  SE_stream_bind_output_column = _SE_stream_bind_output_column
  SE_stream_set_spatial_constraints = _SE_stream_set_spatial_constraints
  SE_stream_query = _SE_stream_query
  SE_stream_create = _SE_stream_create
  SE_sql_construct_alloc = _SE_sql_construct_alloc
  SE_shape_generate_rectangle = _SE_shape_generate_rectangle
  SE_shape_create = _SE_shape_create
  SE_layerinfo_get_envelope = _SE_layerinfo_get_envelope
  SE_layerinfo_get_coordref = _SE_layerinfo_get_coordref
  SE_coordref_create = _SE_coordref_create
  SE_layer_get_info = _SE_layer_get_info
  SE_layerinfo_create = _SE_layerinfo_create
  SE_connection_create = _SE_connection_create
  SE_error_get_string = _SE_error_get_string
  SE_shape_get_all_points = _SE_shape_get_all_points
  SE_shape_get_num_points = _SE_shape_get_num_points
  SE_shape_get_type = _SE_shape_get_type
  SE_shape_get_num_parts = _SE_shape_get_num_parts

Place this file in the same directory as the SDE80.LIB file and use the
Microsoft 32-bit LIB utility with the /MACHINE and /DEF switches eg.

LIB /MACHINE:i386 /DEF:SDE80.DEF

This will alter the SDE80.LIB library so when linking the library with
the
rest of mapserver the symbol reference are resolved and hence the
problem is
solved. Compile the program as before and all your problems should
disappear.

For more Information see:
Microsoft Systems Journal
July 1996
Under the Hood
Written by Matt Pietrek (71774.362 at compuserve.com)

Compiling Mapserver with SDE support on win32 written by
Egon Kuster
Defence Science & Technology Organisation
egon.kuster at dsto.defence.gov.au

-----Original Message-----
From: Stephen Lime [mailto:steve.lime at dnr.state.mn.us]
Sent: Tuesday, 13 February 2001 7:15 AM
To: Egon.Kuster at dsto.defence.gov.au
Subject: Re: SDE HELP!

Hi Egon: I've never tried it myself on NT. My development version is
sde8
and platform is
solaris 2.7. The conversion warnings are probably no big deal. The
unresolved symbol
problems are the big concern. What version of SDE are you running? You
might
check
the ESRI SDE site for tips on compiling/linking win32 executables. Again
this should work
but I'm afraid this is virgin territory so it might be kinda painfull
getting it to work.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Kuster, Egon" <Egon.Kuster at dsto.defence.gov.au> 02/11/01 10:16PM >>>
I am trying to compile mapserver with the SDE support, I get the
following
compile errors:

C:\mapserver\source\mapserver>nmake Makefile.vc

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cd gd-1.2
        nmake /f makefile.nt OPTFLAGS="/nologo /Zi /W3 /DDEBUG"

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cl gddemo.obj -o gddemo /link /LIBPATH:. gd.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:gddemo.exe
/out:gddemo.exe
/LIBPATH:.
gd.lib
gddemo.obj
        cl giftogd.obj -o giftogd       /link /LIBPATH:. gd.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:giftogd.exe
/out:giftogd.exe
/LIBPATH:.
gd.lib
giftogd.obj
        cl webgif.obj -o webgif /link /LIBPATH:. gd.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:webgif.exe
/out:webgif.exe
/LIBPATH:.
gd.lib
webgif.obj
        cd ..
        cd gdft
        nmake /f makefile.vc OPTFLAGS="/nologo /Zi /W3 /DDEBUG"

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cd ..
        cl /nologo /Zi /W3 /DDEBUG -I./gd-1.2   -I../freetype/lib
-I./gdft
-I./regex-0.12 -IC:\arcgis\arcexe81\arcsde\include -DHAVE_STRING_H
-DREGEX_MALLOC -DNEED_STRCASECMP -DNEED_STRNCASECMP   -DUSE_EPPL 
-DUSE_TTF
-DUSE_GD_1_2 -DUSE_SDE mapserv.c mapserver.lib gd-1.2/gd.lib
./freetype/lib/freetype.lib ./gdft/gdft.lib
C:\arcgis\arcexe81\arcsde\lib\*.lib
mapserv.c
mapserv.c(165) : warning C4018: '!=' : signed/unsigned mismatch
mapserv.c(230) : warning C4244: '=' : conversion from 'double ' to 'int
',
possible loss of data
mapserv.c(239) : warning C4244: '=' : conversion from 'double ' to 'int
',
possible loss of data
mapserv.c(579) : warning C4244: '=' : conversion from 'double ' to 'int
',
possible loss of data
mapserv.c(580) : warning C4244: '=' : conversion from 'double ' to 'int
',
possible loss of data
mapserv.c(605) : warning C4244: '=' : conversion from 'double ' to 'int
',
possible loss of data
mapserv.c(606) : warning C4244: '=' : conversion from 'double ' to 'int
',
possible loss of data
LIBC.lib(crt0init.obj) : warning LNK4098: defaultlib "libcd.lib"
conflicts
with use of other libs; use /NODEFAULTLIB:library
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_connection_free
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_free
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_free
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_clip
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_is_nil
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_fetch
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_execute
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_describe_column
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_bind_output_column
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_set_spatial_constraints
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_query
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_stream_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_sql_construct_alloc
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_generate_rectangle
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layerinfo_get_envelope
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layerinfo_get_coordref
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_coordref_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layer_get_info
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_layerinfo_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_connection_create
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_error_get_string
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_all_points
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_num_points
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_type
mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
_SE_shape_get_num_parts
mapserv.exe : fatal error LNK1120: 26 unresolved externals
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

What version of the SDE API did you use when writing mapserver, do you
have
a distribution of mapserver that I can use that contains SDE support or
do
you have any pointers for trying to run mapserver with connecting to the
ESRI SDE.

I have also attached a copy of the make file that I am using.
<<Makefile.vc>>

Egon Kuster
Defence, Science & Technology Organisation
Information Technology Division
Australia
Phone: +61 8 8259 5175
Fax: +61 8 8259 5169
Email: egon.kuster at dsto.defence.gov.au


Eduin Yesid Carrillo wrote:
> 
> Hi list.
> Please give me any hint for this error in vc6 and mapsde.c. Micosoft
> Knowledge Base give some workarounds for this error, but I don't know how
> implement them for sg.h (ArcSDE).
> All 26 times that mapsde.c call SDE functions, generates this error:
> 
> *******
>    Creating library mapserv.lib and object mapserv.exp
> mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
> _SE_connection_free
> mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
> _SE_shape_free
> ...
> mapserver.lib(mapsde.obj) : error LNK2001: unresolved external symbol
> _SE_shape_get_num_parts
> mapserv.exe : fatal error LNK1120: 26 unresolved externals
> NMAKE : fatal error U1077: '"C:\Archivos de programa\Microsoft Visual
> Studio\VC98\BIN\link.exe"' : return code '0x460'
> Stop.
> Error executing NMAKE.
> *******
> 
> >From Microsoft:
> http://support.microsoft.com/support/kb/articles/Q123/7/68.asp?LN=EN-US&SD=gn&FR=0&qry=unresolved%20external%20symbol&rnk=6&src=DHCS_MSPSS_gn_SRCH&SPR=VCC
> 
> CAUSE
> Inline functions are not visible outside of the source file where they are
> defined. The Inline Specifier section in the C++ Language Reference states,
> "Functions that are declared as inline and that are not class member
> functions have internal linkage unless otherwise specified."
> 
> RESOLUTION
> Here are five possible workarounds:
> **Declare the inline function with the extern keyword to force external
> linkage. Note, however, that using extern with class member functions will
> cause a warning with /Ze, and an error with /Za.
> -or-
> **Move the function definition to the header file so it's included in each
> translation unit used.
> -or-
> **Remove the inline specification.
> -or-
> **Force a function version of the inline function to be created in the
> module that it is defined in. You can do this by referencing the address of
> the inline function, by assigning it to a function pointer, or by passing it
> to a function.
> -or-
> **Remove the /Ob1 (Only Inline) or /Ob2 (Any suitable) option from the
> command line and compile with /Ob0 (Disable). The /Ob0 option is the default
> if no options are specified.
> 
> STATUS
> This behavior is by design.
> 
> Thanks in advanced.
> 
> Eduin Yesid Carrillo
> 
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



More information about the mapserver-users mailing list