2

I'm try how to use RTKlib (All of the library functions and APIs were written in ANSI C (C89)). The library are organize like this: rtklib.h file1.c ... file1.c ...

With QT (in ubuntu 32), I start a new project/application. In this project I Add Existing Directory directory (rtklib library) (every .c files and rtklib.h). In the rtklib.h there is:

#ifdef __cplusplus
extern "C" {
#endif

OK, now I include in my .cpp file:

#include "rtklib.h"

And in my .pro file:

INCLUDEPATH += $$PWD/src

When I try to run, there are a error: undefined reference to 'showmsg' in some .c files (18 error like that). Maybe I need to do some compilers configuration?

Can some one help me?

Thanks

1 Answers1

0

You have to add the following to your .pro file:

LIBS += -lrtk

This will link the library to your project (you might have to adjust the name, I don't know the exact filename of the library).

Shadowigor
  • 181
  • 7
  • OK, but I need to compile the rtklib (c codes) before enter to QT? It means that I need to use gcc compile the rtklib, and after use the LIB += to link to the rtklib.a? Or the QT can compile it together and link it? – Sarvio Valente Mar 17 '17 at 18:33
  • Ah, I assumed the library was precompiled. You can of course do that, just add all source files to the SOURCES variable ('SOURCES += ...'). Then you don't need the LIBS line anymore. – Shadowigor Mar 17 '17 at 19:34
  • That is I did. I put every c file and the rtklib.h file. After I use insert for "rtklib.h" in the mainwindows.cpp. – Sarvio Valente Mar 17 '17 at 19:41
  • Hm. Can you find the .c-file where showmsg is defined? Is that also in SOURCES? If yes, is there an 'extern "C"' around them? I think it has to be around both or neither, but I'm not entirely sure. If that doesn't work, try taking away the 'extern "C"' everywhere. That's only really needed for precompiled libraries. – Shadowigor Mar 17 '17 at 19:50
  • Now its work fine. What I did. I compile the library first. After I remove every c-file from my QT project. I insert one rtklib.h. I include rtklib.h in the CPP file and insert the compile library by QT option menu with right click (its configure my .pro file automatically). Thanks you for your help. – Sarvio Valente Mar 17 '17 at 22:00