Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to use GEOS library in QT Creator - Win platform



  • Hi i want to use GEOS (Geometry Engine - Open Source) library in QT, in static way.

    I downloaded version 3.2.0,(http://download.osgeo.org/geos/)
    because it have Visual c++ project file, and i don not how to compile new version on win, then form visual C++ 2008 Express open the VC project file:
    geos-3.2.0\build\msvc90\geos_lib.vcproj
    And build the lib in debug and release version,
    Then get a file named geos.lib of 223MB.

    In the QtCreator pro file add the lib

    win32:LIBS += $$PWD/librerias/geos.lib
    QMAKE_LFLAGS += -Xlinker -Bstatic
    CONFIG += no_lflags_merge

    INCLUDEPATH += $$PWD/librerias
    DEPENDPATH += $$PWD/librerias

    In my cpp test code file, put the include:
    #include "librerias/geos_c.h"

    And in a slot:
    initGEOS(notice, log_and_exit);
    qDebug()<< "GEOS version " << GEOSversion();

    But when compile i get:
    error: undefined reference to `initGEOS'

    error: undefined reference to `GEOSversion()'

    What i am doing wrong?

    Greetings


  • Lifetime Qt Champion

    Hi
    In creator, you are using the same VS 2008 compiler?

    Its looks correct. and you link to .lib as VS likes.
    But the big question is if the geos.lib is a static lib ?



  • Thanks for the reply; In Qt creator I use mingw,
    The lib and the program must to be compiled with the same compiler,
    or can compile the lib with VS2008 and the program with mingw?

    I do not have experience with external libs, i am stuck with this problem.


  • Lifetime Qt Champion

    Hi,

    No, on Windows you need to have everything built with the same compiler if you are using C++ libraries.



  • Hi, thanks for the reply, so now try to compile the lib with mingw,
    download the MSYS, open the shell, go to the folder, and write:

    ./configure
    After some messages get:

    configure: error: no acceptable C compiler found in $PATH

    Reading some forums, mus to add a fstab file
    the etc/fstab file is:

    #Win32_Path Mount_Point
    c:/Qt/Qt5.4.1/5.4/mingw491_32/ /mingw

    Also i try with /bin
    #Win32_Path Mount_Point
    C:/Qt/Qt5.4.1/5.4/mingw491_32/bin

    Also try
    ./configure --prefix=/mingw


    $ mount
    c:\Qt\Qt5.4.1\5.4\mingw491_32 on /mingw type user (binmode)


    $ g++
    sh: g++: command not found


    $ gcc
    sh: gcc: command not found

    There is not gcc.exe or g++.exe file in the c:\Qt\Qt5.4.1\5.4\mingw491_32\bin folder

    What can be wrong


  • Lifetime Qt Champion

    @marceloarguello700 You should use MinGW provided with your Qt installation instead of using MSYS.



  • @jsulm Thanks for the reply, but it is to short to my knowledge,
    How must to proceed, open Qt Creator and make a new project, or
    open a win console an so what??
    Greetings



  • @marceloarguello700 If I have some problems with Qt build toolchan on Windows, I simply uninstall entire Qt, and make clean reinstall after that. On installation I tick in "Tools" MinGW of the latest version and in the list above I tick "Prebuilt components" for MinGW of the same version as it has been ticked earlier.
    P.S. English is not my mother tongue, sorry for the mistakes, hope you understood all.


  • Lifetime Qt Champion

    @marceloarguello700 First you need to install MinGW. To do so start the Qt Maintenance Tool go to "Add or remove components" select Tools/MinGW_LATEST_VERSION (currently 5.3.0). Then use that compiler instead of MSYS.


Log in to reply