Hi!
Most likely problem is with UNICODE. By default NetXMS is build in UNICODE mode, so it uses wchar_t for all characters. I suppose that your program built as non-UNICODE, so it actually passes char to functions from libappagent that actually expects wchar_t. I'd recommend to build app agent separately with UNICODE disabled and link that version with your application.
For example, you can configure NetXMS sources like this:
./configure --with-sdk --disable-unicode --prefix=/opt/nxsdk
and then build you application adding
-I /opt/nxsdk/include -L /opt/nxsdk/lib -lappagent -lnetxms
You can get slightly more diagnostic from app agent by setting nxlolg debug callback:
nxlog_set_debug_writer(DebugWriter);
nxlog_set_debug_level(9);
With debug writer similar to this:
static void DebugWriter(const TCHAR *tag, const TCHAR *format, va_list args)
{
if (tag != nullptr)
printf("[%s] ",tag);
vprintf(format, args);
printf("\n");
}
Attached is functional example for reference. I've compiled it as following:
g++ -o demoapp demoapp.cpp -I /opt/nxsdk/include -L /opt/nxsdk/lib -lappagent -lnetxms
Sample app output:
victor@xps13:~/Source/appagentdemo$ LD_LIBRARY_PATH=/opt/nxsdk/lib ./demoapp
Initializing AppAgent...
Starting AppAgent...
Application agent startedApp started
NamedPipeListener(appagent.DEMOAPP): waiting for connection
NamedPipeListener(appagent.DEMOAPP): accepted connection by user victor
nxappget output:
victor@xps13:~$ /opt/netxms/bin/nxappget DEMOAPP DemoApp.Metric1
OK
victor@xps13:~$
Hope this helps!
Best regards,
Victor
demoapp.cpp