[Gdal-dev] Problems Linking with Stubs in the precompiled downloadable Win32 Binaries.

Chapman, Martin MChapman at sanz.com
Mon May 10 18:51:13 EDT 2004


Louis,

I'm not sure about this, but it may be the order in which your vc++
platform sdk's are linked into your app.  I've had this problem with
other apps before.  You need to have them in the right order or you will
get this problem.  Goto tools->options->projects->vc++ directories and
they should be linked in somewhat the following order:

$(VCInstallDir)lib
$(VCInstallDir)atlmfc\lib
$(VCInstallDir)PlatformSDK\lib\prerelease
$(VCInstallDir)PlatformSDK\lib
$(FrameworkSDKDir)lib

Although this will be machine independent depending on what sdk's you
have installed.

Just a thought...

Martin

-----Original Message-----
From: Fam. Pool [mailto:marisap at telkomsa.net] 
Sent: Monday, May 10, 2004 3:25 PM
To: gdal-dev at remotesensing.org
Subject: RE: [Gdal-dev] Problems Linking with Stubs in the precompiled
downloadable Win32 Binaries.


Sorry I'm bothering you so much with this Frank -

I tried compiling GDAL from scratch but I got linking problems again.
These are my woes -


Microsoft (R) Library Manager Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

        link /dll /debug /INCLUDE:_OCTNewCoordinateTransformation
/INCLUDE:_OGRRegisterAll  /INCLUDE:_OGRFeatureStylePu
ller  /INCLUDE:_OSRValidate  /INCLUDE:_OPTGetProjectionMethods
/INCLUDE:_OGR_G_GetPointCount /INCLUDE:_GDALSimpleImageW arp
/INCLUDE:_GDALSuggestedWarpOutput  /INCLUDE:_GDALGCPTransform
/INCLUDE:_GDALComputeMedianCutPCT  /INCLUDE:_GDALDit herRGB2PCT
port\*.obj gcore\*.obj alg\*.obj frmts\o\*.obj
ogr\ogrsf_frmts\ogrsf_frmts.lib ogr\ogr.lib   D:\Libraries\Xer
ces/lib/xerces-c_2.lib   odbc32.lib
D:\Libraries\Jasper\src\msvc\Win32_Release\libjasper.lib
/out:gdal1
2.dll /implib:gdal_i.lib
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in
MSVCRT.lib(MSVCRT.dll)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
MSVCRT.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
MSVCRT.lib(cinitexe.obj)
LIBC.lib(mbctype.obj) : error LNK2005: __getmbcp already defined in
MSVCRT.lib(MSVCRT.dll)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __strdup already defined in
LIBC.lib(strdup.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __unlink already defined in
LIBC.lib(unlink.obj)
LIBC.lib(crt0dat.obj) : warning LNK4006: _exit already defined in
MSVCRT.lib(MSVCRT.dll); second definition ignored
LIBC.lib(crt0init.obj) : warning LNK4006: ___xc_z already defined in
MSVCRT.lib(cinitexe.obj); second definition ignored

LIBC.lib(crt0init.obj) : warning LNK4006: ___xc_a already defined in
MSVCRT.lib(cinitexe.obj); second definition ignored

LIBC.lib(crt0init.obj) : warning LNK4006: ___xi_z already defined in
MSVCRT.lib(cinitexe.obj); second definition ignored

LIBC.lib(crt0init.obj) : warning LNK4006: ___xi_a already defined in
MSVCRT.lib(cinitexe.obj); second definition ignored

LIBC.lib(mbctype.obj) : warning LNK4006: __getmbcp already defined in
MSVCRT.lib(MSVCRT.dll); second definition ignored
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __strdup already defined in
LIBC.lib(strdup.obj); second definition ignored
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __unlink already defined in
LIBC.lib(unlink.obj); second definition ignored
   Creating library gdal_i.lib and object gdal_i.exp
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other
libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib
"LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
gdal12.dll : fatal error LNK1120: 1 unresolved externals NMAKE : fatal
error U1077: 'link' : return code '0x460' Stop.


I vainly tried removing the MSVCRT and LIBC default libs by adding
/NODEFAULTLIB:LIBC and /NODEFAULTLIB:MSVCRT to LINKER_FLAGS in nmake.opt
- but I guess you can imagine how many unresolved symbols I got then.
Anyway, I'm using VC6 and I was wondering if that would cause any
problems... I noticed your precompiled binaries specifically look for
MSVCRT71.dll

I don't want to whine 'cause I really hate whiners, but I would really
appreciate it if you could direct me to a site where I can download
precompiled WIN32 Static Libs for GDAL and OGR. Or put one up if there
aren't any - actually any help would be dearly appreciated!

Thanks in advance,
Louis.


-----Original Message-----
From: gdal-dev-admin at remotesensing.org
[mailto:gdal-dev-admin at remotesensing.org]On Behalf Of Fam. Pool
Sent: 10 May 2004 10:59
To: gdal-dev at remotesensing.org
Subject: RE: [Gdal-dev] Problems Linking with Stubs in the precompiled
downloadable Win32 Binaries.


Fo Sheezy -

This is a simplified version of the code - note that I'm using a MapInfo
Data Source, a directory with several .TAB, .DAT, .MAP etc files (so in
GDAL
talk: a couple 'o Layers).

bool cVectorLoader::loadOGRVector(char* sVectorMap)
{
  //DataSet
  OGRDataSource* poDataSet = (OGRDataSource*)
OGRSFDriverRegistrar::Open(sVectorMap, false);
  if (poDataSet == NULL)
  {
    return false;
  }

  const char* sName = poDataSet->GetName();
  int iNrOfLayers = poDataSet->GetLayerCount();

  cout << endl << "<OGR> Report for Vector Dataset " << sName << endl;
  cout << "Dataset has " << iNrOfLayers << " layer(s)." << endl;

  //Layers
  for (int i=0; i < iNrOfLayers; i++)
  {
    cout << "For layer " << i+1 << endl;

    OGRLayer* poLayer = (OGRLayer*) poDataSet->GetLayer(i);
    if (poLayer != NULL)
    {
      //Features
      int iNrOfFeatures = poLayer->GetFeatureCount(true);
      OGRFeature* poFeature = (OGRFeature*) poLayer->GetNextFeature();

      cout << "Layer has " << iNrOfFeatures << " features" << endl;

      int j=1;
      while (poFeature != NULL)
      {
        //Style
        cout << "Feature " << j << " with ID " << poFeature->GetFID()
             << " and Style String " << poFeature->GetStyleString () <<
endl;

        OGRStyleTable oStyleTable;
        OGRStyleTool* poStyleTool;
        OGRStyleMgr*  poStyleMgr = new OGRStyleMgr(&oStyleTable);

        poStyleMgr->GetStyleString(poFeature);
        for (int k=0; poStyleMgr->GetPartCount(); k++)
        {
           poStyleTool = poStyleMgr->GetPart(k);
           switch(poStyleTool->GetType())
           {
             case OGRSTCNone: cout << "Style = None" << endl;
              break;
             case OGRSTCPen: cout << "Style = Pen" << endl;
              break;
             case OGRSTCBrush: cout << "Style = Brush" << endl;
              break;
             case OGRSTCSymbol: cout << "Style = Symbol" << endl;
              break;
             case OGRSTCLabel: cout << "Style = Label" << endl;
              break;
           }
        }

        ...

        poFeature = (OGRFeature*) poLayer->GetNextFeature();
        j++;
      }
    }
  }
  cout << endl << "<OGR> End of Report" << endl;

  //Clean up
  delete poDataSet;

  //Function completed successfully
  return true;
}

Compilation is all good. When linking I get ze following errors.

Linking...
   Creating library Debug/MapViewer.lib and object Debug/MapViewer.exp
cMapVisual.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStylePen" (?asStylePen@@3PAUogr_style_param@@A)
cVectorLoader.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStylePen" (?asStylePen@@3PAUogr_style_param@@A)
MapViewer.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStylePen" (?asStylePen@@3PAUogr_style_param@@A)
cMapVisual.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleBrush" (?asStyleBrush@@3PAUogr_style_param@@A)
cVectorLoader.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleBrush" (?asStyleBrush@@3PAUogr_style_param@@A)
MapViewer.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleBrush" (?asStyleBrush@@3PAUogr_style_param@@A)
cMapVisual.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleSymbol"
(?asStyleSymbol@@3PAUogr_style_param@@A)
cVectorLoader.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleSymbol"
(?asStyleSymbol@@3PAUogr_style_param@@A)
MapViewer.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleSymbol"
(?asStyleSymbol@@3PAUogr_style_param@@A)
cMapVisual.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleLabel" (?asStyleLabel@@3PAUogr_style_param@@A)
cVectorLoader.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleLabel" (?asStyleLabel@@3PAUogr_style_param@@A)
MapViewer.obj : error LNK2001: unresolved external symbol "struct
ogr_style_param *  asStyleLabel" (?asStyleLabel@@3PAUogr_style_param@@A)
Debug/MapViewer.exe : fatal error LNK1120: 4 unresolved externals Error
executing link.exe.

I'm using gdal_i.lib => gdal12.dll, the ones from the downloadable
binaries. I should add that for the past three yrs I've been a Java Boy
and for the last two weeks I've been brushing up on my C skills, which I
haven't used since my Varsity days. I could just be doing something
stupid. However, everything links fine when I comment out the Style Tool
thingies.

BTW Frank - thanks for the great library!

Louis.





-----Original Message-----
From: gdal-dev-admin at remotesensing.org
[mailto:gdal-dev-admin at remotesensing.org]On Behalf Of Frank Warmerdam
Sent: 10 May 2004 10:09
To: gdal-dev at remotesensing.org
Subject: Re: [Gdal-dev] Problems Linking with Stubs in the precompiled
downloadable Win32 Binaries.


Fam. Pool wrote:
> Hi,
>
> I'm quite new to the GDAL world and sofar its gone quite smoothly - 
> but today I tried using OGR Style Tools and now I'm getting unresolved

> symbol errors when linking the libs. Its just looks as tho something 
> was left out of the precompiled binaries. I'm going to try building 
> the GDAL package
from
> scratch and see if the stubs the scripts generate solve the problem.
Still,
> I like doing things the easy way. If someone could verify the 
> integrity of the pre-compiled Win32 binaries that would be swell.

Louis,

There are indeed some issues with linking against the DLL version of OGR
and using some of the style related classes.  I am a bit uncertain what
the exact problem is, but if you can list your link errors, and provide
a smallish example program that demonstrates the problem I will try and
fix it.  I have run into a similar problem with MapServer but never
succeeded in resolve it.

Note, the problem can be worked around by linking against static
versions of OGR but if possible i would prefer to just fix the base
problem.

Best regards,
--
---------------------------------------+--------------------------------
---------------------------------------+----
--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
Gdal-dev mailing list
Gdal-dev at remotesensing.org
http://remotesensing.org/mailman/listinfo/gdal-dev

_______________________________________________
Gdal-dev mailing list
Gdal-dev at remotesensing.org
http://remotesensing.org/mailman/listinfo/gdal-dev

_______________________________________________
Gdal-dev mailing list
Gdal-dev at remotesensing.org
http://remotesensing.org/mailman/listinfo/gdal-dev



More information about the Gdal-dev mailing list