Important: Please read the Qt Code of Conduct -

Error: undefined reference to '_imp___ZN8BamTools9BamReaderC1Ev', when using BamTools library:

  • I want to use the BamTools API in my qt project. I am using Qt5.2 on Windows 7.

    I downloaded and made the BamTools library following the instructions at

    In the BamTools/lib directory i have the files: "libbamtools-utils.a"; "libjsoncpp.a"; "libbamtools.a";
    "libbamtools.dll"; and "libbamtools.dll.a".

    In my .pro file i have the following:
    LIBS += -L$$PWD/../../BamTools/lib/ -llibbamtools

    INCLUDEPATH += $$PWD/../../BamTools/include
    DEPENDPATH += $$PWD/../../BamTools/include

    When I try to create a BamReader object in one of my .cpp files, i get the error: undefined reference to '_ imp___ZN8BamTools9BamReaderC1Ev'.

    I have no idea how to fix this sort of error and have been searching the internet for something but cant find anything relavant. This is the first time I have tried to use a library in a Qt project, so I'm not sure if I'm doing that wrong or there's something wrong with the library I made. Any help would be much appreciated.

  • What compiler do you use? VisualStudio or MinGW.

    I'm not sure about VS, for MinGW I think it should be
    LIBS += -L$$PWD/../../BamTools/lib/ -lbamtools

    Note -lbamtools without lib.

  • andreyc, I still get the same error when I use '-lbamtools'.

    Good question about which compiler, actually I tried both MinGW and VS and I get the same error with both.

  • I don't think this error is related to Qt.

    The undefined symbol _ imp___ZN8BamTools9BamReaderC1E is a C++ mangled name for BamTools::BamReader::BamReader()

    Check if you build library correctly.
    If you have an utility nm with MinGW then you can use it
    nm -C|grep BamReader

    Create a simple example that uses bamtool without Qt and try to build it with the libbamtools. It may help to investigate the problem.

    Another idea, don't mix libraries build with MinGW and VS.
    Use only one tool for all your libs and apps.

Log in to reply