Hi all.

Have created C Library code of a Matlab function which compiles under Qt fine:

Qt Code:
  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2013-07-27T19:09:07
  4. #
  5. #-------------------------------------------------
  6.  
  7. QT -= gui
  8.  
  9. CONFIG += staticlib
  10.  
  11. TARGET = KalmanFilter
  12.  
  13. TEMPLATE = lib
  14.  
  15. DEFINES += KALMANFILTER_LIBRARY
  16.  
  17. SOURCES += \
  18. rtGetNaN.c \
  19. rtGetInf.c \
  20. rt_nonfinite.c \
  21. kalmanfilter.c \
  22. kalmanfilter_terminate.c \
  23. kalmanfilter_initialize.c \
  24. kalmanfilter_data.c
  25.  
  26. HEADERS += \
  27. rtwtypes.h \
  28. rtGetNaN.h \
  29. rtGetInf.h \
  30. rt_nonfinite.h \
  31. kalmanfilter.h \
  32. kalmanfilter_types.h \
  33. kalmanfilter_terminate.h \
  34. kalmanfilter_initialize.h \
  35. kalmanfilter_data.h
  36.  
  37. INCLUDEPATH += "/home/david/Development/Matlab/kaltest/coderdemo_kalman_filter" \
  38. /home/david/Matlab/toolbox/shared/simtargets \
  39. /home/david/Matlab/extern/include \
  40. /home/david/Matlab/simulink/include
  41.  
  42. target.path = /usr/lib
  43.  
  44. INSTALLS += target
  45.  
  46. OTHER_FILES +=
To copy to clipboard, switch view to plain text mode 

The library (when "make" then "sudo make install") successfully compiles and installs to /usr/lib
However, when I try to utilise in another Qt application, it the compile fails as follows:

Qt Code:
  1. testclass.o: In function `TestClass':
  2. /home/david/Development/Qt/GenTest/testclass.cpp:12: undefined reference to `kalmanfilter_initialize()'
  3. testclass.o: In function `TestClass::run()':
  4. /home/david/Development/Qt/GenTest/testclass.cpp:22: undefined reference to `kalmanfilter(double const*, double*)'
  5. collect2: ld returned 1 exit status
  6. make: *** [GenTest] Error 1
  7. 10:23:56: The process "/usr/bin/make" exited with code 2.
  8. Error while building/deploying project GenTest (kit: Desktop Qt 5.1.0 GCC 64bit)
  9. When executing step 'Make'
To copy to clipboard, switch view to plain text mode 

The application looks as follows:

PRO File

Qt Code:
  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2013-07-23T16:47:17
  4. #
  5. #-------------------------------------------------
  6.  
  7. QT += core
  8.  
  9. QT -= gui
  10.  
  11. TARGET = GenTest
  12. CONFIG += console
  13. CONFIG -= app_bundle
  14.  
  15. TEMPLATE = app
  16.  
  17. SOURCES += \
  18. main.cpp \
  19. testclass.cpp
  20.  
  21. HEADERS += \
  22. testclass.h
  23.  
  24. LIBS += -L/usr/lib -lKalmanFilter
  25.  
  26. INCLUDEPATH += $$PWD/../KalmanFilter
  27.  
  28. DEPENDPATH += $$PWD/../KalmanFilter
To copy to clipboard, switch view to plain text mode 

main.cpp

Qt Code:
  1. #include <QCoreApplication>
  2. #include "testclass.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QCoreApplication a(argc, argv);
  7.  
  8. TestClass *tc = new TestClass();
  9. tc->run();
  10.  
  11. return a.exec();
  12. }
To copy to clipboard, switch view to plain text mode 

Class Header

Qt Code:
  1. #ifndef TESTCLASS_H
  2. #define TESTCLASS_H
  3.  
  4. #include <QObject>
  5. #include "kalmanfilter.h"
  6.  
  7. class TestClass : public QObject
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit TestClass(QObject *parent = 0);
  12. void run();
  13.  
  14. signals:
  15.  
  16. public slots:
  17.  
  18. private:
  19. real_T z[2];
  20. real_T y[2];
  21. };
  22.  
  23. #endif // TESTCLASS_H
To copy to clipboard, switch view to plain text mode 

Class File

Qt Code:
  1. #include "testclass.h"
  2. #include "kalmanfilter.h"
  3. #include "kalmanfilter_initialize.h"
  4. #include "kalmanfilter_data.h"
  5. #include "kalmanfilter_terminate.h"
  6.  
  7. #include <QDebug>
  8.  
  9. TestClass::TestClass(QObject *parent) :
  10. QObject(parent)
  11. {
  12. kalmanfilter_initialize();
  13. }
  14.  
  15. void TestClass::run()
  16. {
  17. for (real_T r1 = 0; r1 < 10; r1++)
  18. {
  19. z[0] = r1;
  20. z[1] = r1;
  21.  
  22. kalmanfilter(z,y);
  23.  
  24. qDebug() << "Z = " << z[0] << "," << z[1];
  25. qDebug() << "Zest = " << y[0] << "," << y[1];
  26. }
  27. }
To copy to clipboard, switch view to plain text mode 

Many thanks in advance