* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+extern "C" {
+#include <sigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
+#include <stdint.h>
+#include <libsigrok/libsigrok.h>
+}
+
#include <QtGui/QApplication>
+#include <QDebug>
#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;
}
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)
+}