From: Joel Holdsworth Date: Fri, 11 May 2012 08:48:50 +0000 (+0100) Subject: Link in libsigrok and libsigrokdecode X-Git-Tag: pulseview-0.1.0~361 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=664fca5cd49e79b2906e1c91fa60764b164acd90;p=pulseview.git Link in libsigrok and libsigrokdecode --- diff --git a/main.cpp b/main.cpp index 80b9ec93..bb95f9ba 100644 --- a/main.cpp +++ b/main.cpp @@ -18,19 +18,50 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +extern "C" { +#include /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#include +#include +} + #include +#include #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; - w.show(); /* Set some application metadata. */ QApplication::setApplicationVersion(APP_VERSION); QApplication::setApplicationName("sigrok-qt"); QApplication::setOrganizationDomain("http://www.sigrok.org"); - return a.exec(); + /* Initialise libsigrok */ + if (sr_init() != SR_OK) { + qDebug() << "ERROR: libsigrok init failed."; + return 1; + } + + /* Initialise libsigrokdecode */ + if (srd_init(NULL) != SRD_OK) { + qDebug() << "ERROR: libsigrokdecode init failed."; + return 1; + } + + /* Load the protocol decoders */ + srd_decoder_load_all(); + + /* Initialise the main window */ + MainWindow w; + w.show(); + + /* Run the application */ + const int ret = a.exec(); + + /* Destroy libsigrokdecode and libsigrok */ + srd_exit(); + sr_exit(); + + return ret; } diff --git a/sigrok-qt2.pro b/sigrok-qt2.pro index a93b9bc3..dde53996 100644 --- a/sigrok-qt2.pro +++ b/sigrok-qt2.pro @@ -19,3 +19,19 @@ SOURCES += main.cpp\ HEADERS += mainwindow.h FORMS += mainwindow.ui + +# libsigrok and libsigrokdecode +# TODO: Check for the minimum versions of libsigrok/libsigrokdecode we need. +win32 { + # On Windows/MinGW we need to use '--libs --static'. + # We also need to strip some stray '\n' characters here. + QMAKE_CXXFLAGS += $$system(pkg-config --cflags libsigrokdecode \ + libsigrok | sed s/\n//g) + LIBS += $$system(pkg-config --libs --static libsigrokdecode \ + libsigrok | sed s/\n//g) +} else { + QMAKE_CXXFLAGS += $$system(pkg-config --cflags libsigrokdecode) + QMAKE_CXXFLAGS += $$system(pkg-config --cflags libsigrok) + LIBS += $$system(pkg-config --libs libsigrokdecode) + LIBS += $$system(pkg-config --libs libsigrok) +}