I'm trying to use a C library in a C++ program. I want to link the library libcoap.a to my program. I've already made a huge program in Qt so it can't be solved by using make instead of qmake.
As a simple example I've made the following code.
connection.h:
#include <string>
#include "coap.h"
void sendData(std::string);
connection.cpp:
#include "connection.h"
#include "coap.h"
coap_uri_t uri;
void sendData(std::string ip){
coap_split_uri((unsigned char *)ip.c_str(), strlen(ip.c_str()), &uri );
}
main.cpp:
#include "connection.h"
using namespace std;
int main()
{
sendData("[aaaa::c30c:0:0:2]/sen/lt");
return 0;
}
coaptester.pro:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
unix:!macx:!symbian: LIBS += -L$$PWD/../commTest/commTest/libcoap-4.0.1/ -lcoap
INCLUDEPATH += $$PWD/../commTest/commTest/libcoap-4.0.1
DEPENDPATH += $$PWD/../commTest/commTest/libcoap-4.0.1
unix:!macx:!symbian: PRE_TARGETDEPS += $$PWD/../commTest/commTest/libcoap-4.0.1/libcoap.a
SOURCES += main.cpp \
connection.cpp
HEADERS += \
connection.h
I always get the same error:
undefined reference to `coap_split_uri(unsigned char*, unsigned int, coap_uri_t*)'
collect2: ld returned 1 exit status
Thanks in advance.