Results 1 to 4 of 4

Thread: How to create a QT application that uses BASS library (un4seen)?

  1. #1
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default How to create a QT application that uses BASS library (un4seen)?

    Hi @ all,

    after several problems building the new QT5 with MinGW for X64 on Windows 7, it finally works.

    Now I want to play a simple mp3 file. the QMediaPlayer ssems to require a lot of system resources, so I am trying some different librarys.

    My development enviroment is the QT Creator and I have the following directories:

    c:\qt\qt5 (containing the compiled QT5 directories like qtbase etc)
    c:\qt\mingw64-4.7.2 (including the bin / lib / include etc directories)

    I have downloaded the BASS for 64bit from here http://www.un4seen.com/forum/?topic=9038

    I have added the following lines to my .pro file

    Qt Code:
    1. win32: LIBS += -L$$PWD/lib/ -lbass
    2.  
    3. INCLUDEPATH += $$PWD/
    4. DEPENDPATH += $$PWD/
    To copy to clipboard, switch view to plain text mode 

    The "lib" folder contains only the bass.lib file. The bass.dll is in the compiler output directory (there where the created exe file will be created).

    In the constructor of my dialog I have the following code:

    Qt Code:
    1. ....
    2. #include "bass.h"
    3. ....
    4. ....
    5. Player::Player(QWidget *parent) :
    6. QDialog(parent),
    7. ui(new Ui::Player)
    8. {
    9. int mybassVersion;
    10. mybassVersion = BASS_GetVersion();
    11. if (mybassVersion!=BASSVERSION) {
    12. QMessageBox msgBox;
    13. msgBox.setText("An incorrect version of BASS.DLL was loaded");
    14. msgBox.exec();
    15. }
    16. ....
    17. }
    To copy to clipboard, switch view to plain text mode 

    But everytime I start the program, the program terminated with an "Segmentation fault" message.

    I haven't started with writing the source code I want (to play an MP3 file) because the "basic functions" doesn't work.

    Can someone help me to get this simple program run?

    Maybe someone has a little demo application of how to use the BASS library with the QT creator.

    Thank you very much.

    Best regards,

    Rainer

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,719
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How to create a QT application that uses BASS library (un4seen)?

    This isn't really a Qt question, and you haven't shown enough code to diagnose where the error might be. It is probably completely unrelated to this BASS library and is most likely something you are doing wrong elsewhere.

    Have you actually stepped into your code using the debugger to find out where the segmentation fault occurs? Or you simply running the program and watching it fail?

  3. #3
    Join Date
    Nov 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create a QT application that uses BASS library (un4seen)?

    I know, that this is not a direct Qt question. Sorry.

    Here is my code:

    bassTest.pro
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2013-02-01T20:52:02
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = bassTest
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. dialog.cpp
    17.  
    18. HEADERS += dialog.h\
    19. bass.h
    20.  
    21. FORMS += dialog.ui
    22.  
    23. win32: LIBS += -L$$PWD/lib/ -lbass
    24.  
    25. INCLUDEPATH += $$PWD/
    26. DEPENDPATH += $$PWD/
    To copy to clipboard, switch view to plain text mode 

    dialog.cpp
    Qt Code:
    1. #include "dialog.h"
    2. #include "ui_dialog.h"
    3. #include "bass.h"
    4. #include <QMessageBox>
    5.  
    6. Dialog::Dialog(QWidget *parent) :
    7. QDialog(parent),
    8. ui(new Ui::Dialog)
    9. {
    10. ui->setupUi(this);
    11. QMessageBox msgBox;
    12.  
    13. if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
    14. msgBox.setText("An incorrect version of BASS.DLL was loaded");
    15. }
    16. else {
    17. msgBox.setText("A correct version of BASS.DLL was loaded");
    18. }
    19.  
    20. msgBox.exec();
    21.  
    22. }
    23.  
    24. Dialog::~Dialog()
    25. {
    26. delete ui;
    27. }
    To copy to clipboard, switch view to plain text mode 


    The error occurs during while using the debugger in line 13.

    Qt Code:
    1. if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
    To copy to clipboard, switch view to plain text mode 

    A correct base.dll is in the same folder like the exe-file.

    Any ideas?

    I have attached the complete sourcecode as a zip file.
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,719
    Thanks
    259
    Thanked 760 Times in 750 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How to create a QT application that uses BASS library (un4seen)?

    In bass.h there is at least one method that looks to be a prerequisite for any operations using the library:

    Qt Code:
    1. HPLUGIN BASSDEF(BASS_PluginLoad)( const char * file, DWORD flags );
    To copy to clipboard, switch view to plain text mode 

    Perhaps you should start by reading the BASS documentation and looking at any example programs that might be in either your downloaded code or on the library's web site.

    Edit: Maybe I am wrong about that - this function may just be for loading plugins for use with BASS, not the BASS library itself. In a simple example from the BASS distribution, the WinMain() method does exactly what you are doing:

    Qt Code:
    1. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
    2. {
    3. // check the correct BASS was loaded
    4. if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
    5. MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
    6. return 0;
    7. }
    8.  
    9. // display the window
    10. DialogBox(hInstance,MAKEINTRESOURCE(1000),NULL,&dialogproc);
    11.  
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    So my guess is that you might be linking a release version of the library to the debug version of the executable. This generally doesn't work in Windoze.
    Last edited by d_stranz; 1st February 2013 at 22:19.

Similar Threads

  1. Create and use library Qt creator
    By posixprogrammer in forum Newbie
    Replies: 1
    Last Post: 28th February 2011, 10:59
  2. Replies: 2
    Last Post: 19th February 2011, 12:26
  3. Replies: 4
    Last Post: 18th December 2009, 19:55
  4. How create a dll/ library with Qt
    By ccosta in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 23:02
  5. File format not recognized -- bass.dll
    By youkai in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2009, 13:26

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.