[Resolved] Errors including NEFIS library

  • 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,


  • 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.

  • 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 \
    LIBS += -L$$PWD/thirdparty/netcdf/libs -lnetcdf -lhdf5 -lz -lcurl \
            -L$$PWD/thirdparty/nefis/libs -lnefis
    INCLUDEPATH += include $$PWD/thirdparty/nefis/src/include \
    RESOURCES += \
    RC_FILE = resources.rc


  • Lifetime Qt Champion


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

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


    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,


  • 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" {

    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.

  • Lifetime Qt Champion

    IIRC, you can also use

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

Log in to reply

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