Results 1 to 19 of 19

Thread: Qt and BASS library?

  1. #1
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default LNK1181 problem

    I want to record sound to file using Qt and BASS library. I previously added these libraries to my other project (main one), but I decided to not make mess there until I will be sure that code works and makes sense. It looked like that in .pro file:

    LIBS += -lbass
    LIBS += -LC:/BASS/x64
    INCLUDEPATH += C:/BASS/c

    LIBS += -lbasswasapi
    LIBS += -LC:/BASSWASAPI/x64
    INCLUDEPATH += C:/BASSWASAPI/c

    LIBS += -lbassenc
    LIBS += -LC:/BASSENC/x64
    INCLUDEPATH += C:/BASSENC/c
    And compiler did not say a thing about any problems with finding files after I included them (I could normally see and use their functions). I decided to make new test application to check if things I want to do there actually work, copied these include paths to new .pro file, included .h files in my SoundRecord class, and then wanted to build a clean project to see if everything works. I got this:

    LNK1181: cannot open input file 'basswasapi.lib'
    Same compiler, same toolset, same include paths in .pro file and it just refuses to work. It can find basswasapi.h , but for some reason it can't find actual library.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: LNK1181 problem

    Try placing the -L options in LIBS before the corresponding -l options.

  3. #3
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Qt and BASS library?

    I want to make application that records sound from loopback, and I don't really have big choice of external libraries that have WASAPI wrapped. I wrote class using BASS library that is supposed to do the job, few people saw it's insides and there are most probably no coding errors in .h and .cpp files. Yet Qt totally refuses to compile it, no matter what I do - use x64 or x86 libraries, x64 or x86 compiler, and I probably tried most of the working combinations there. What compiler is supposed to be used with BASS library to make it work?

    This is the closeset to sucessful compilation error log (only 4 of them):



    It's x64 BASS library(libraries), and I tried to compile it with Qt 5.5.0 MSVC 2013 + Visual C++ 12.0 x86 amd64 compiler. I assume that these errors are related to linking problems.

    This is my .pro file:

    Qt Code:
    1. QT += core gui
    2.  
    3. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    4.  
    5. INCLUDEPATH += "D:\BASS\c"
    6. LIBS += -L"D:\BASS\c\x64" \
    7. -lbass
    8.  
    9. INCLUDEPATH += "D:\BASSWASAPI\c"
    10. LIBS += -L"D:\BASSWASAPI\c\x64" \
    11. -lbasswasapi
    12.  
    13. INCLUDEPATH += "D:\BASSENC\c"
    14. LIBS += -L"D:\BASSENC\c\x64" \
    15. -lbassenc
    16.  
    17. TARGET = nienazwany
    18. TEMPLATE = app
    19.  
    20.  
    21. SOURCES += main.cpp\
    22. mainwindow.cpp \
    23. audio_capture_bass.cpp
    24.  
    25. HEADERS += mainwindow.h \
    26. audio_capture_bass.h
    27.  
    28. FORMS += mainwindow.ui
    To copy to clipboard, switch view to plain text mode 

    This is .h file of this class:

    Qt Code:
    1. #ifndef AUDIO_CAPTURE_BASS_H
    2. #define AUDIO_CAPTURE_BASS_H
    3.  
    4. #include <QObject>
    5. #include "bass.h"
    6. #include "basswasapi.h"
    7. #include "bassenc.h"
    8.  
    9. class Audio_Capture_BASS : public QObject
    10. {
    11. Q_OBJECT
    12. public:
    13. explicit Audio_Capture_BASS(QObject *parent = 0);
    14.  
    15. signals:
    16.  
    17. public slots:
    18.  
    19. void start_recording();
    20. void stop_recording();
    21.  
    22. private:
    23.  
    24. HSTREAM sound_stream;
    25. static DWORD CALLBACK WasapiProc(void *buffer, DWORD length, void *user);
    26. BASS_WASAPI_INFO info;
    27.  
    28. };
    29.  
    30. #endif // AUDIO_CAPTURE_BASS_H
    To copy to clipboard, switch view to plain text mode 

    And finally .cpp file:

    Qt Code:
    1. #include "audio_capture_bass.h"
    2.  
    3. Audio_Capture_BASS::Audio_Capture_BASS(QObject *parent) : QObject(parent)
    4. {
    5.  
    6. BASS_Init(0, 44100, 0, 0, 0); //initialization of silent BASS device
    7. BASS_WASAPI_Init(-3, 0, 0, 0, 0.5, 0,WasapiProc, this); //initialization of default WASAPI loopback capture device
    8. BASS_WASAPI_GetInfo(&info); //getting info about stream parameters
    9.  
    10. }
    11.  
    12.  
    13. //recording function called by BASS_WASAPI_Init every 0.5 second
    14. DWORD CALLBACK Audio_Capture_BASS::WasapiProc(void *buffer, DWORD length, void *user)
    15. {
    16.  
    17. Audio_Capture_BASS *self = (Audio_Capture_BASS*)user;
    18. BASS_ChannelGetData(self->sound_stream, buffer, length);
    19. return 1;
    20.  
    21. }
    22.  
    23. void Audio_Capture_BASS::start_recording()
    24. {
    25.  
    26. sound_stream = BASS_StreamCreate(info.freq, info.chans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_DUMMY, 0); //creating a stream(HSTREAM)
    27. BASS_Encode_Start(sound_stream, "output.wav", BASS_ENCODE_PCM|BASS_ENCODE_FP_16BIT|BASS_ENCODE_AUTOFREE, NULL, NULL); //adding WAV encoder to stream
    28. BASS_WASAPI_Start(); //start WASAPI stream output
    29.  
    30. }
    31.  
    32. void Audio_Capture_BASS::stop_recording()
    33. {
    34.  
    35. BASS_WASAPI_Stop(true); //stopping WASAPI stream output
    36. BASS_StreamFree(sound_stream); //stopping recording stream together with encoder
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 

    What am I missing or what am I doing wrong? Or maybe BASS just won't work with Qt?
    Attached Images Attached Images
    Last edited by Khaine; 5th September 2015 at 13:40.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt and BASS library?

    Quote Originally Posted by Khaine View Post
    Yet Qt totally refuses to compile it
    Qt is a set of libraries, it doesn't compile anything.

    Quote Originally Posted by Khaine View Post
    This is the closeset to sucessful compilation error log (only 4 of them):
    I assume that these errors are related to linking problems.
    Yes.

    As you can see these are all for symbols of the BASS library, the symbols of the other two seem to be found nicely.
    Check that the problematic library is actually where you think it is and named the way your pro file expects.

    If that is OK, try moving the LIBS statement for it to a place after the other two.

    Quote Originally Posted by Khaine View Post
    Or maybe BASS just won't work with Qt?
    Your Qt code compiled just fine (otherwise you wouldn't reach the linker stage).

    Cheers,
    _

  5. #5
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    Check that the problematic library is actually where you think it is and named the way your pro file expects.

    If that is OK, try moving the LIBS statement for it to a place after the other two.
    Yes, it is where it is. QMake don't report any errors. I moved this statement to the end and nothing changes.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt and BASS library?

    Just to verify that the other two libraries are found correctly, could you try building with the problematic lines commented out?

    Cheers,
    _

  7. #7
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    Quote Originally Posted by anda_skoa View Post
    Just to verify that the other two libraries are found correctly, could you try building with the problematic lines commented out?

    Cheers,
    _
    I did. It compiles and run but program crashes instantly. There are no objects of this class created, it's only included in mainwindow. Rest of the program is empty.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt and BASS library?

    Quote Originally Posted by Khaine View Post
    I did. It compiles and run but program crashes instantly.
    Right, that was to be expected.

    But since the functions from the other two libraries got resolved correctly it is a strong indication that the compiler and bitness are correct.

    I am out of ideas, but I don't use Windows a lot so there might be still things to check.

    Cheers,
    _

  9. #9
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    What can it be actually? What may be wrong if program crashes right away even without creating any object of this class?

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt and BASS library?

    Quote Originally Posted by Khaine View Post
    What may be wrong if program crashes right away even without creating any object of this class?
    That is likely just a side effect of using uninitialized data structures, e.g. sounds_stream.

    Cheers,
    _

  11. #11
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    So what do you propose to resolve it? Define it within constructor? There is no object of this class anyway. Not even declaration. It has no actual reason to crash. Header is included in mainwindow.h and that's all.
    Last edited by Khaine; 5th September 2015 at 16:44.

  12. #12
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt and BASS library?

    Quote Originally Posted by Khaine View Post
    It has no actual reason to crash.
    Accessing an unitialized variable has undefined behavior, so yes, crashing is likely.
    [/quote]

    Quote Originally Posted by Khaine View Post
    So what do you propose to resolve it?
    Likely solved by executing the code you currently have commented out.

    Why spend time fixing a problem that might not exist once you get the linking problem resolved?

    Cheers,
    _

  13. #13
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    Why spend time fixing a problem that might not exist once you get the linking problem resolved?
    I agree, but still - how to resolve linking problem? I tried most of the Qt toolsets and tried to add these libraries through "Add library", and nothing worked so far.

  14. #14
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt and BASS library?

    Firstly, i would switch the backslashes for forward slashes in the paths so that the warnings from qmake about these do not obscure anything important
    Qt Code:
    1. LIBS += -L"D:/BASS/c/x64" -lbass
    To copy to clipboard, switch view to plain text mode 
    Etc. Rerun. Qmake and nmake.

    I would check that "D:/BASS/c/x64" contains a file "bass.lib". I woulb be fussy about the capitalisation of the file name just to be sure. If Bass needs to be "installed" after being built then make sure that has happenned and you are using the installed files in their installed paths.

    I would try to compile a single file program with a main() and call to Bass_Init() and nothing else.

  15. #15
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?



    Unfortunately even this doesn't work. Insides of .pro file:

    Qt Code:
    1. QT += core
    2. QT -= gui
    3.  
    4. TARGET = Unnamed
    5. CONFIG += console
    6. CONFIG -= app_bundle
    7.  
    8. TEMPLATE = app
    9.  
    10. SOURCES += main.cpp
    11.  
    12. INCLUDEPATH += "D:/BASS/c"
    13. LIBS += -L"D:/BASS/c" \
    14. -lbass
    To copy to clipboard, switch view to plain text mode 
    Last edited by Khaine; 6th September 2015 at 00:23.

  16. #16
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt and BASS library?

    The problem is that the library does not exist anywhere you have told the linker to look. This really has nothing much to do with Qt. Post a directory listing of the content of the the d:/bass/c folder.

  17. #17
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    BASS.jpg

    You have to forgive me polish version of Windows, but if only Qt wants .lib file, then it's there for sure.

  18. #18
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt and BASS library?

    Is that a 32-bit or 64-bit lib file? Are you building a 32- or 64-bit application?

  19. #19
    Join Date
    Sep 2015
    Posts
    36
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    1

    Default Re: Qt and BASS library?

    It's all 32 bits right now. Error in console application says now:

    Cannot obtain a handle to the inferior: The parameter is incorrect.
    And error for simple Qt widgets app:

    Starting C:\Users\Michal\Documents\build-nienazwany-Desktop_Qt_5_5_0_MSVC2013_32bit-Release\release\nienazwany.exe...
    The program has unexpectedly finished.
    C:\Users\Michal\Documents\build-nienazwany-Desktop_Qt_5_5_0_MSVC2013_32bit-Release\release\nienazwany.exe crashed
    And this is what debugger says about it:


    images hosting
    Attached Images Attached Images
    Last edited by Khaine; 8th September 2015 at 11:19.

Similar Threads

  1. Replies: 3
    Last Post: 1st February 2013, 20:41
  2. Replies: 3
    Last Post: 20th December 2012, 12:48
  3. Dynamic library on Mac, Library not loaded
    By grayfox in forum Newbie
    Replies: 2
    Last Post: 2nd July 2011, 02:42
  4. Replies: 2
    Last Post: 19th February 2011, 11:26
  5. File format not recognized -- bass.dll
    By youkai in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2009, 12:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.