Home > Software engineering >  OPCUA sdk include path
OPCUA sdk include path

Time:09-24

I have trouble with include uaplatformlayer.h in example from OPCUA client example. I found this example in SDK. I tried to do own makefile, to build example client lesson01. I use Visual Studio Code. It can't find this .h file.

#include "uaplatformlayer.h"
#include "sampleclient.h"

int main(int, char*[])

{    
    UaStatus status;

    // Initialize the UA Stack platform layer
    UaPlatformLayer::init();

    // Create instance of SampleClient
    SampleClient* pMyClient = new SampleClient();

    return 0;
}

it still replies...

g   -g -Wall  -c client_cpp_sdk_tutorial.cpp
client_cpp_sdk_tutorial.cpp:1:10: fatal error: uaplatformlayer.h: Adresář nebo soubor neexistuje
    1 | #include "uaplatformlayer.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:9: client_cpp_sdk_tutorial.o] Chyba 1
The terminal process "bash '-c', '/home/michal/Dokumenty/OPCUA_adapter/sdk/examples/client_gettingstarted/lesson01/build.sh'" failed to launch (exit code: 2)

I think my problem is in makefile, but I don't have any idea where is the mistake.

Could anyone help me, please? Does anyone experiance with OPCUA SDK?

cc=g  
cflags=-g -Wall 
libflags=-L/home/michal/Dokumenty/OPCUA_adapter/sdk/lib -luamoduled -luamodelsd -lcoremoduled -luabasecppd -luastackd -lxmlparsercppd -luapkicppd -luaclientcppd -lxml2 -lssl -lcrypto
includes=-I/home/michal/Dokumenty/OPCUA_adapter/sdk/include/uabasecpp -I/home/michal/Dokumenty/OPCUA_adapter/sdk/include/uastack
objfiles=client_cpp_sdk_tutorial.o sampleclient.o
vystup=aplikace

%.o : %.cpp
    $(cc) $(cflags) -c $<

# startovaci pravidlo
vychozi: $(vystup)

# zavislosti
dep:
    $(cc) -MM *.cpp >dep.list

-include dep.list

clean:

    rm aplikace $(objfiles)

# slinkování aplikace
$(vystup): $(objfiles)
    $(cc) $(cflags) $(objfiles) $(includes) $(libflags) -o $@

CodePudding user response:

You need to add "includes" to the recipe for the .o files:

%.o : %.cpp
    $(cc) $(cflags) $(includes) -c $<
  • Related