Reputation: 57
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?
Upvotes: 0
Views: 875
Reputation: 648
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.
Upvotes: 0