0

I want to use libsndfile library in a Qt project, then I need to link it but I always get an error :

    main.cpp:129: error : undefined reference to `sf_open'
    main.cpp:137: error : undefined reference to `sf_write_short'

I tried to add these lines to my .pro

1) INCLUDEPATH += C:/libsndfile/include LIBS += -LC:/libsndfile/lib/libsndfile-1.lib

2) INCLUDEPATH += C:/libsndfile/include/ LIBS += C:/libsndfile/lib/libsndfile-1.lib

3) win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../libsndfile/lib/ -llibsndfile-1

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

win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../../../libsndfile/lib/libsndfile-1.lib

Can you help me ,please, to link sndfile library correctly?

e492109
  • 57
  • 1
  • 3

1 Answers1

0
LIBS+= -L<PATH TO DIR WITH DLL> -lsndfile-1

For example:

LIBS+= -LC:/sndfile -lsndfile-1

Of course the library itself must be compiled with the compiler you use (mingw?). Don't try to use VS-compiled library with MinGW and vice versa.

DmitryARN
  • 648
  • 3
  • 10
  • I think that's the answer I was looking for. How do I know where a lib was compiled? I'm trying to use a third-party library, I have tried almost every combination of linking to the .lib, the .dll and still getting the undefined reference error. – mquasar Feb 18 '21 at 03:02