Error of "undefined reference to"

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
Kangskii
Full Member
Full Member
Posts: 9
Joined: 21 Sep 2016, 04:15

Error of "undefined reference to"

Post by Kangskii »

Dear Support Team,

I am now developing a C++ project using Eclipse. The project will be cross-compiled and downloaded to an Intel-based embedded system with Linux Yocto OS.
The SDK source code was compiled by GCC 5.3.0. I am going to include the HELLOWorld sample into my project.
When I add the two lines of code:
UaXmlDocument::initParser();
UaPlatformLayer::init();

to the main function, there are a bunch whole of error on "undefined reference to XXX ",
such as:
\example.cpp:45: undefined reference to `getAppPath()'
\opcserver.cpp:62: undefined reference to `UaCoreServerApplication::isStarted()'
\opcserver.cpp:47: undefined reference to `UaServerApplication::UaServerApplication()'
\opcserver.cpp:64: undefined reference to `UaLocalizedText::~UaLocalizedText()'
....

I have add INCLUDEPATHS of header files: uastack, uabase, ...
And LINKER configurations are:
-lmraa -fno-use-linker-plugin -L"D:\SDK_Destination\OPCUAsdk\lib" -luabase -lcoremodule -luamodels -luamodule -luapki -luastack -lxmlparser

It seems that the compiler cannot find the lib files. I searched on the internet and found someone said that "libraries must be specified in a specific order". Which order should I specify ?
Can you help to clear this problem ?

The main function of my project is:

#include <iostream>
using namespace std;
#include "mraa.hpp"
//---new added header files--
#include "opcserver.h"
#include "shutdown.h"
#include "uaplatformlayer.h"
#include "uathread.h"
#if SUPPORT_XML_PARSER
#include "xmldocument.h"
#endif



using namespace mraa;


int main(void)
{
cout << "Hello IOT2000." << endl;

int ret = 0;
//Linux specific: Signal handlers
RegisterSignalHandler();
//- Initialize the environment --------------
// Initialize the XML Parser
#if SUPPORT_XML_PARSER
// Initialize the XML Parser
UaXmlDocument::initParser();
#endif
ret = UaPlatformLayer::init();

return ret;
}

User avatar
Support Team
Hero Member
Hero Member
Posts: 3069
Joined: 18 Mar 2011, 15:09

Re: Error of "undefined reference to"

Post by Support Team »

Hello Kangskii,

the order is:
-lxmlparser
-lxml2
-luamodule
-lcoremodule
-luapki
-luabase
-luastack
-lssl
-lcrypto
-lpthread
Best regards
Unified Automation Support Team

Kangskii
Full Member
Full Member
Posts: 9
Joined: 21 Sep 2016, 04:15

Re: Error of "undefined reference to"

Post by Kangskii »

Hi Support team,

The libraries that I used are:
-luabase -lcoremodule -luamodels -luamodule -luapki -luastack -lxmlparser

According to the order you specified:
"-lxmlparser -lcoremodule -lcoremodule -luapki -luabase -luastack"
where should I put the 'luamodels ' ?
Thanks.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3069
Joined: 18 Mar 2011, 15:09

Re: Error of "undefined reference to"

Post by Support Team »

uamodels, uamodule, coremodule
Best regards
Unified Automation Support Team

Post Reply