|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Including shapelib.dll in Visual C++ 2008 Express projectHi 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 |
|
|
Re: Including shapelib.dll in Visual C++ 2008 Express projectHi 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@...>
_______________________________________________ Shapelib mailing list Shapelib@... http://lists.maptools.org/mailman/listinfo/shapelib |
|
|
Re: Including shapelib.dll in Visual C++ 2008 Express projectHi 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
|
|
|
Re: Including shapelib.dll in Visual C++ 2008 Express projectHi Raphael,
I think that Dllimport definition and re-definition of shapelib api are not necessary, but I don't know what is the cause... So, please refer the attach file (includes shapelib and shapelib-api call sample(copy from shpcreate.c), and both build successfully in my environment). Regards, Sanak. 2009/6/22 raphael_mws <r.speck@...>
_______________________________________________ Shapelib mailing list Shapelib@... http://lists.maptools.org/mailman/listinfo/shapelib |
|
|
Re: Including shapelib.dll in Visual C++ 2008 Express projectHi Sanak, thank you very much, your example builds also in my environment. This helps a lot. Enjoy the rest of the sunday, regards Raphael
|
| Free embeddable forum powered by Nabble | Forum Help |