Galil and Qt on Windows 7



  • Hi there,

    I am trying to create a simple application to connect to a Galil controller and followed their install instructions (http://www.galilmc.com/sw/pub/all/doc/gclib/html/windows.html).

    However, it appears that it cannot find the functions provided by the library (e.g. GClose() used below in the cpp code). The error message is "undefined reference to `GClose@4' ."

    Is there an issue with my .pro file (shown below)?

    Thank you!!

    Details:

    I started using the serial port terminal example from Qt and added the following .h file:

    #ifndef GRIFFIN_H
    #define GRIFFIN_H

    #include "gclib.h"
    #include "gclibo.h"
    #include "gclib_errors.h"
    #include "gclib_record.h"

    class Griffin
    {

    private:
    GCon *m_g;
    GCStringIn m_IP_ADDR = "10.63.32.65";
    int m_SPEED = 20;

    public:
    Griffin();
    ~Griffin();
    int connect();
    };

    #endif // GRIFFIN_H

    The corresponding .cpp file is:

    #include "griffin.h"
    #include <iomanip>
    #include <iostream>

    Griffin::Griffin()
    {
    m_g = new GCon;
    }

    Griffin::~Griffin()
    {
    GClose(m_g);
    delete m_g;
    }

    int Griffin::connect()
    {
    //GCStringIn openParams(" -d -t 10000");
    //std::cout << openParams << std::endl;
    //GOpen();
    return(0);
    }

    I copied to .dll .lib and .h files to a local directory and edited the .pro file as follows:

    QT += widgets serialport

    TARGET = terminal
    TEMPLATE = app

    SOURCES +=
    main.cpp
    mainwindow.cpp
    settingsdialog.cpp
    console.cpp
    griffin.cpp

    HEADERS +=
    mainwindow.h
    settingsdialog.h
    console.h
    griffin.h

    FORMS +=
    mainwindow.ui
    settingsdialog.ui

    RESOURCES +=
    terminal.qrc

    target.path = $$[QT_INSTALL_EXAMPLES]/serialport/terminal
    INSTALLS += target

    LIBS += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/gclib.lib"
    LIBS += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/gclibo.lib"

    INCLUDEPATH += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/"
    DEPENDPATH += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/"
    QT += widgets serialport

    TARGET = terminal
    TEMPLATE = app

    SOURCES +=
    main.cpp
    mainwindow.cpp
    settingsdialog.cpp
    console.cpp
    griffin.cpp

    HEADERS +=
    mainwindow.h
    settingsdialog.h
    console.h
    griffin.h

    FORMS +=
    mainwindow.ui
    settingsdialog.ui

    RESOURCES +=
    terminal.qrc

    target.path = $$[QT_INSTALL_EXAMPLES]/serialport/terminal
    INSTALLS += target

    LIBS += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/gclib.lib"
    LIBS += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/gclibo.lib"

    INCLUDEPATH += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/"
    DEPENDPATH += "C:/Magnetic_tracking/NDI/Code/terminal/GalilLibrary/"



  • To add:

    in gclib.h it says:

    //set library visibility for gcc and msvc
    #if BUILDING_GCLIB && HAVE_VISIBILITY
    #define GCLIB_DLL_EXPORTED attribute((visibility("default")))
    #elif BUILDING_GCLIB && defined _MSC_VER
    #define GCLIB_DLL_EXPORTED __declspec(dllexport)
    #elif defined _MSC_VER
    #define GCLIB_DLL_EXPORTED __declspec(dllimport)
    #else
    #define GCLIB_DLL_EXPORTED
    #endif

    and

    //! Closes a connection to a Galil Controller.
    GCLIB_DLL_EXPORTED GReturn GCALL GClose(GCon g);

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Which exact version of Qt are you using to build your application ?



  • @SGaist
    Hi, thank you!

    Qt Creator 4.0.2
    Based on Qt 5.7.0 (MSVC 2013, 32 bit)


  • Lifetime Qt Champion

    That's the Qt Creator version, what Qt version are you using ?



  • @SGaist
    It's 5.7.0
    From the build settings:
    Desktop Qt 5.7.0 MinGW 32bit



  • @SGaist
    DependencyWalker identified issues with a bunch of DLL dependencies (API-MS-WIN-CORE_WINRT- ...).

    This led me to this thread:

    https://stackoverflow.com/questions/17023419/win-7-64-bit-dll-problems

    This issue may not be related to Qt after all but rather be caused by a missing Visual studio "redistributable package."


  • Lifetime Qt Champion

    With which compiler is your version of Galil compiled ?



  • @SGaist
    I believe I found the issue:

    Galil's installer placed the *.dll in a different path than the *.lib files:

    ..\gclib\dll\x86

    versus

    ..\gclib\lib\dynamic\x86

    When I copied the *.dll files to the same folder as the *.lib files, the problem went away.


Log in to reply
 

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