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

>> Sent from the ShapeLib mailing list archive at Nabble.com.<br>
>><br>
>> _______________________________________________<br>
>> Shapelib mailing list<br>
>> <a href="mailto:Shapelib@lists.maptools.org">Shapelib@lists.maptools.org</a><br>
>> <a href="http://lists.maptools.org/mailman/listinfo/shapelib" target="_blank">http://lists.maptools.org/mailman/listinfo/shapelib</a><br>
>><br>
><br>
> _______________________________________________<br>
> Shapelib mailing list<br>
> <a href="mailto:Shapelib@lists.maptools.org">Shapelib@lists.maptools.org</a><br>
> <a href="http://lists.maptools.org/mailman/listinfo/shapelib" target="_blank">http://lists.maptools.org/mailman/listinfo/shapelib</a><br>
><br>
><br>
<br>
</div></div><font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Including-shapelib.dll-in-Visual-C%2B%2B-2008-Express-project-tp24132517p24136300.html" target="_blank">http://www.nabble.com/Including-shapelib.dll-in-Visual-C%2B%2B-2008-Express-project-tp24132517p24136300.html</a><br>

</font><div><div></div><div class="h5">Sent from the ShapeLib mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
Shapelib mailing list<br>
<a href="mailto:Shapelib@lists.maptools.org">Shapelib@lists.maptools.org</a><br>
<a href="http://lists.maptools.org/mailman/listinfo/shapelib" target="_blank">http://lists.maptools.org/mailman/listinfo/shapelib</a><br>
</div></div></blockquote></div><br>