Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Resolved] Errors including NEFIS library
Forum Updated to NodeBB v4.3 + New Features

[Resolved] Errors including NEFIS library

Scheduled Pinned Locked Moved General and Desktop
dll
7 Posts 3 Posters 2.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goalie39
    wrote on last edited by goalie39
    #1

    Hi All -

    I've been working for a few nights now trying to get the NEFIS library (Distributed by Deltares in the Netherlands) included in a project of mine. For some reason, this is giving me a real headache. Deltares includes a visual studio project file which did not yield a usable dll, so I figured I would just make my own project in Qt to build the library, however, I seem to get undefined reference errors when trying to include it in my project that will use it. I'm not fluent enough in C/C++/Qt to really get into what is going on here, so I was hoping someone might be able to take a look and give me a suggestion. I've placed a copy of the library on a transfer site in case anyone does have a second to take a peek. My hunch is something is screwy when some of the function names are redefined, and it is just something that evades my knowledge.

    Link: we. tl/ Oru7X0xo1W

    Thanks all,

    Zach

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NetZwerg
      wrote on last edited by
      #2

      Hello goalie39,

      would it be possible to actually post the error given by the compiler/linker? I would guess the desired library may just depend on another library being present or the linker is not given the correct information. Please post the error itself and a copy of your .pro file.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goalie39
        wrote on last edited by
        #3

        NetZwerg -

        Sure. The error message is as follows:

        mingw32-make[1]: Entering directory 'C:/Users/zcobell/Documents/GitHub/build-MetOceanViewer-Desktop_Qt_5_5_0_MinGW_32bit-Debug'
        g++ -Wl,-subsystem,windows -mthreads -o debug\MetOcean_Viewer.exe object_script.MetOcean_Viewer.Debug  -lmingw32 -LC:/Qt/5.5/mingw492_32/lib -lqtmaind -lshell32 -LC:/Users/zcobell/Documents/GitHub/MetOceanViewer/thirdparty/netcdf/libs -lnetcdf -lhdf5 -lz -lcurl -LC:/Users/zcobell/Documents/GitHub/MetOceanViewer/thirdparty/nefis/libs -lnefis -lQt5WebKitWidgetsd -lQt5Widgetsd -lQt5WebKitd -lQt5Guid -lQt5Networkd -lQt5Xmld -lQt5Cored debug\resources_res.o 
        ./debug\timeseries_data.o: In function `Z9readNefisv':
        C:\Users\zcobell\Documents\GitHub\build-MetOceanViewer-Desktop_Qt_5_5_0_MinGW_32bit-Debug/../MetOceanViewer/src/timeseries_data.cpp:582: undefined reference to `Clsnef(int*)'
        collect2.exe: error: ld returned 1 exit status
        Makefile.Debug:134: recipe for target 'debug\MetOcean_Viewer.exe' failed
        

        And my .pro file is as follows:

        QT       += core gui webkitwidgets network xml
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = MetOcean_Viewer
        TEMPLATE = app
        
        
        SOURCES += src/main.cpp\
            src/ui_hwm_tab.cpp \
            src/ui_noaa_tab.cpp \
            src/ui_usgs_tab.cpp \
            src/hwm_data.cpp \
            src/hwm_functions.cpp \
            src/noaa_functions.cpp \
            src/usgs_functions.cpp \
            src/general_functions.cpp \
            src/timeseries_data.cpp \
            src/timeseries_functions.cpp \
            src/timeseries_add_data.cpp \
            src/ui_timeseries_tab.cpp \
            src/about_dialog.cpp \
            src/fileio.cpp \
            src/MetOceanViewer_main.cpp \
        
        HEADERS  += \
            include/hwm.h \
            include/timeseries_add_data.h \
            include/timeseries.h \
            include/about_dialog.h \
            version.h \
            include/MetOceanViewer.h \
        
        FORMS    += \
            ui/timeseries_add_data.ui \
            ui/about_dialog.ui \
            ui/MetOceanViewer_main.ui
        
        OTHER_FILES +=
        
        LIBS += -L$$PWD/thirdparty/netcdf/libs -lnetcdf -lhdf5 -lz -lcurl \
                -L$$PWD/thirdparty/nefis/libs -lnefis
        
        INCLUDEPATH += include $$PWD/thirdparty/nefis/src/include \
                               $$PWD/thirdparty/netcdf/include
        
        RESOURCES += \
            MetOceanViewer.qrc
        
        RC_FILE = resources.rc
        

        Thanks!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Maybe a silly question, but are you sure you have everything for the same architecture ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Maybe a silly question, but are you sure you have everything for the same architecture ?

            G Offline
            G Offline
            goalie39
            wrote on last edited by
            #5

            @SGaist I believe I have. I've tried to create a simple test project to replicate the issue. I've placed it here:

            http://we.tl/jxCNmJOoPE

            There are two .pro files in the archive. One is the test project (which is just the default project with a couple extra routines tossed in) and the other is one to build the DLL. (in the nefis folder). I'm pretty sure i'm just not doing something fairly simple right, but I'm a bit green on some of this so I'm sure an experienced set of eyes would realize my mistake pretty quickly.

            I've also tried contacting the developers of the library, but they haven't been much help to this point, unfortunately.

            Thanks for your time,

            Zach

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goalie39
              wrote on last edited by
              #6

              Wow. My hunch about it being something simple was dead on the money. Even an old FORTRAN programmer knows when it should be easy and it isn't. Turns out my self taught C/C++ didn't include the section on setting up headers for calls between C and C++ libraries. For the netCDF libraries, which I've used in the past, they were already set with:

              #if defined(__cplusplus)
              extern "C" {
              #endif

              However, the NEFIS library was not, which is what caused the issue. Now that I've set these flags in the header, things are working as expected. Thanks for all your guys help, as always.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                IIRC, you can also use

                extern "C" {
                #include "mycinclude.h"
                }
                

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved