Need to compile C library, PROJ4



  • Hi I am making a GIS software, and then need to make some coordenates system translation.
    For the job is widely used the PROJ4 library https://github.com/OSGeo/proj.4.
    I include the principal header to my cpp file:
    extern "C"
    {
    #include <proj_api.h>
    }

    Also include many files of src folder to my qt project.
    I only need to use this functions:
    void pj_free(projPJ proj)
    projPJ pj_init_plus(const char *defn)
    int pj_transform(projPJ src_cs, projPJ dst_cs, long point_count,
    double *x, double *y, double *z)

    But when compile with QtCreator have the nexts errors:
    error: undefined reference to pj_etmerc' error: undefined reference topj_s_etmerc'
    error: undefined reference to pj_rouss' error: undefined reference topj_s_rouss'
    The problem is that names does not exist in the src folder or in the git hub folder.
    We couldn't find any code matching 'pj_etmerc'
    I try with 4-4.9.1 and 4-4.8 version and both give me the same errors.

    Where can find a list with only the neded files to use the above functions?
    something like project file

    What can be wrong?
    Te library is writed in C languaje it is very indescifrable to my knowledge.
    Please help me



  • Why don't you compile it and use it as a shared library (.dll, .so)? It would be much easier, I guess. And if you need the other functions in the future, they'll be readily available.



  • pj_s_rouss comes from src/proj_rouss.c
    Also the proj_api.h is already wrapped in extern "C" as you can see
    if you read it.

    But as Leanordo said you should build the whole thing and if you don't
    want to ship another dynamically linked file with your app, then you
    can just build a static library instead.



  • Thanks for the reply
    my main objetive is make a static library.
    If I knew how to do it??
    my class have a few functions

    bool vtCrsTransform::setSourceEPSG(int EPSG)
    {   search the EPSG id number in a xml file an then init the 
    projection pj_init_plus() with the definition string from the xml}
    
    bool vtCrsTransform::setTargetEPSG(int EPSG)
    {   search the EPSG id number in a xml file an then init the 
    projection pj_init_plus() with the definition string from the xml}
    
    QPointF vtCrsTransform::transform(QPointF pt)
    { apply pj_transform with the source an target projections}
    

    with this i want to make my statics library.

    But there is not something like project file with the neccesary file.

    Greetings


  • Qt Champions 2017

    good start is to read
    https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application
    (section Creating a static library)

    Also you can choose New Project and select library and see what you get.

    I assume you got PROJ4 to compile and now are ready to turn it into a static library ?



  • Thanks, i can compile,
    Add the files one by one until succes.
    now have problem to use the library, but it is for another post.
    Greetings


  • Qt Champions 2017

    @marceloarguello700
    Super.
    If you did make a static library, then you can
    use
    LIBS += -L[path to lib] -l[name of lib]
    in the .pro file.
    or
    click on the .pro file so it opens up. then in the actual file, you right click and there
    is a Add Library which lets you add the library.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.