[Shapelib] Including shapelib.dll in Visual C++ 2008 Express project
raphael_mws
r.speck at minewolf.com
Sun Jun 21 09:44:45 PDT 2009
Hi Sanak,
thanks for the answer. I tried what you told me and rebuilt the shapelib
project with the new C/C++ preprocessor commands, but it didn't change
anything.
I think I am doing something wrong when accessing the DLL functions. This is
a short sample code:
<start>
#define DllImport __declspec( dllimport )
#include <iostream>
#include "stdafx.h"
#include "D:\Visual Studio 2008\Projects\Shapelib-1_2_10-mod\shapefil.h"
using namespace std;
DllImport SHPHandle SHPAPI_CALL SHPOpen();
int _tmain(int argc, _TCHAR* argv[])
{
SHPHandle testhandle; //this works - the compiler finds shapefil.h
SHPOpen("test","test"); //this produces the error
return 0;
}
<end>
This is the compiler output:
1>Verknüpfen... 1>ShapefileCreator.obj : error LNK2019: Verweis auf nicht
aufgelöstes externes Symbol "_SHPOpen" in Funktion "_wmain". 1>D:\Visual
Studio
2008\Projects\ShapefileCreator\ShapefileCreator\Debug\ShapefileCreator.exe :
fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
The same as before.
I added the path to the DLL/LIB file in the Linker section of the VC
property page of my project and to the general search paths. This should be
sufficient, or not?
Regards,
Raphael
Sanak wrote:
>
> Hi Raphael,
>
> It seems that the original Visual C++ shapelib project preprocessor
> definitions are invalid. (generated shapelib.lib and shapelib.dll symbols
> are incompatible)
>
> Please try as follows,
> 1. modify shapelib project C/C++ preprocessor definition from VC property
> page
> SHPAPI_CALL=__stdcall
> --> SHAPELIB_DLLEXPORT
> 2. modify each source files(dbfopen.c/shpopen.c/shptree.c) C/C++
> preprocessor definition from VC property page
> SHAPELIB_EXPORTS;SHPAPI_CALL=__stdcall;$(NoInherit)
> --> SHAPELIB_DLLEXPORT
> 3. rebuild shapelib project.
> 4. import generated shapelib.lib to your project and build.
>
> Regards,
>
> Sanak.
>
> 2009/6/21 raphael_mws <r.speck at minewolf.com>
>
>>
>> Hi folks,
>>
>> I am having a real hard time including the shapelib.dll in my VC++ 2008
>> project. I did the following:
>>
>> - recompile the Visual C++ shapelib project from
>> http://dl.maptools.org/dl/shapelib/contrib/DotNetArchive.zip. This worked
>> fine, and I got the output dll and lib files.
>>
>> - include the shapefil.h in my .cpp file successfully
>>
>> - tried various possibilities to get the shapelib.dll in the correct
>> PATH.
>> Actually, it should be found by the compiler, I even tried putting it
>> into
>> C:\WINDOWS\system32 to make sure that's not the problem.
>>
>> - experimented with various combinations of __declspec( dllimport ) to
>> import the functions from the dll
>>
>> When I try to compile, I always get the following error:
>> "error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_SHPOpen"
>> in
>> Funktion "_wmain"."
>> (in English: unreferenced extern symbol "... )
>>
>> Can anybody please give me a hint what I might be doing wrong? Or, even
>> better, send me a sample VC project using shapelib.dll?
>>
>> Thanks and kind regards,
>> Raphael
>> --
>> View this message in context:
>> http://www.nabble.com/Including-shapelib.dll-in-Visual-C%2B%2B-2008-Express-project-tp24132517p24132517.html
>> Sent from the ShapeLib mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Shapelib mailing list
>> Shapelib at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/shapelib
>>
>
> _______________________________________________
> Shapelib mailing list
> Shapelib at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/shapelib
>
>
--
View this message in context: http://www.nabble.com/Including-shapelib.dll-in-Visual-C%2B%2B-2008-Express-project-tp24132517p24136300.html
Sent from the ShapeLib mailing list archive at Nabble.com.
More information about the Shapelib
mailing list