[Shapelib] Re: Shapelib Digest, Vol 46, Issue 1

Joaquin Perez Valera joaquinperezvalera at gmail.com
Sat Feb 16 21:35:30 EST 2008


Hi

Now I found the way to call the shapelib functions to my program in C++.
There is a sample of my little code, well I took the code from a
shpcreat.cand rename it as
shpcreate.cpp

[Code]
static char rcsid[] =
  "$Id: shpcreate.c,v 1.5 2002/01/15 14:36:07 warmerda Exp $";
#include <iostream>
#include <cstdlib>
#include "shapefil.h"
#include "string.h"


using namespace std;
int main()

{
    SHPHandle    hSHP;
    int        nShapeType;
    string  shape_name;

//Here the program ask for a name
    cout << "Name of the new shapefile?: " << endl;
    getline(cin,shape_name);

    cout << "The program will show the name of the shapefile: " <<
nombre_archivo << endl;

//Here the program creates the shapefile. Gives a name and a type
    nShapeType=5;
    hSHP = SHPCreate( shape_name.c_str(), nShapeType );

    SHPClose( hSHP );

    return 0;
}
[/CODE]

This little program runs in windows with the library in dll and in linux,
but under Linux I must generate and shpopen.o and after compile in this way.

g++ -g shpcreate.cpp shpopen.o -o myprogram

And I have a good result.

The secret was to put include these libraries: cstdlib and string.h.

The way is very easy.
Now I have another problem, but I'll try to solve it myself and if I have
can't I'll ask :)

See you.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20080216/8bf6a35b/attachment.html


More information about the Shapelib mailing list