Arp::Exception - undefined symbol

Hi, Regulary, I get this kind of error in the log files and this time I am completely puzzled about the reason of the problem: 03.05.18 16:39:41.087 root WARN - Unknown XML element ‘Config’ occurs at (/opt/plcnext/projects/PCWE/Plc/Plm/PCWE.acf.config:9)

03.05.18 16:39:41.137 Arp.Plc.Domain.Internal.PlcManager ERROR - Exception occurs while loading plc component ‘Arp.Plc.Plm’: Load: Loading of the library ‘/opt/plcnext/shadowing/libNyxLibrary.so’ failed with error code /opt/plcnext/shadowing/libNyxLibrary.so: undefined symbol : _ZN8NyxTimer 9s _TimeRef E. (Arp::Exception)
03.05.18 16:39:41.166 Arp.Plc.Domain.Internal.PlcManager ERROR - Reverted all yet set up components. The targeted code is quite simple and attached to this post. Reorganizing the code just lead to moving the problem to another static class variable. None of theses variables are externalized through ports. The problem persist after a PLCnext level 1 reset. What is the problem? Thanks PCWE v7.2.2 PLCnext FW v.1.02 --------------------------------------------------- hpp file //#pragma once
//#include “Arp/System/Core/Arp.h”
#include //namespace NyxLibrary { namespace NyxLPC480 {
//using namespace Arp; class NyxTimer
{
public:
NyxTimer(void); static void Reset(int64_t p_MaxDelay);
static bool IsElapsed(void); private:
static std::chrono::steady_clock::time_point s_TimeRef;
static int64_t s_MaxDelay;
}; //}} // end of namespace NyxLibrary::NyxLPC480 --------------------------------------------------- cpp file: //#include “Arp/System/Core/Arp.h”
//#include “Arp/System/Commons/Logging.h”
#include
#include “NyxTimer.hpp” //namespace NyxLibrary { namespace NyxLPC480 {
//using namespace Arp; NyxTimer::NyxTimer(void){} void NyxTimer::Reset(int64_t p_MaxDelayMsec)
{
NyxTimer::s_TimeRef = std::chrono::steady_clock::now();
NyxTimer::s_MaxDelay = p_MaxDelayMsec;
} bool NyxTimer::IsElapsed(void)
{
std::chrono::steady_clock::time_point _now = std::chrono::steady_clock::now();
int64_t _elapsed_secs = std::chrono::duration_cast(_now - NyxTimer::s_TimeRef).count();
// Log::Debug(“Timer time elaspsed (msec) = {0} on {1}”, _elapsed_secs, NyxTimer::s_MaxDelay);
return ( _elapsed_secs > NyxTimer::s_MaxDelay );
} //}} // end of namespace NyxLibrary::NyxLPC480

Hello, where did you place your class NyxTimer?

Are you sure that while compiling it the Binaries were generated and included into your *.so file? (check in the Release folder if the NyxTimer.o is there…) You can add Source Locations in Elicpse at Project->Properties->C/C++ GEneral → Paths and Symobls → Source Location.
There you can see that only the src Folder is actually beeing included into the Project… If this is not the cause: Wich libraries did you Include?
" #include "
I will try to reproduce your issue… kind regards, Oliver

Hi Oliver, The NyxTimer.o exists, and the Class NyxTimer static functions are called from my program Execute() function, so I conclude that this class binary is obligatory linked with the final linker output. I did a “Clean Project” followed by a “Build All” again just to be sure. The binary file timestamps looks alright. My include made in the Program file is: #include “../lib/NyxTimer.hpp” The includes made in the NyxTimer class files are as shown in my first post. I tried with and without ARP stuff (commented out), but both lead to a failure. Suggestion: Is it possible that this actual final validation made at process startup time in the PLCnext could be also executed sooner in the manipulation chain (ex: by EngineeringLibraryBuilder.exe). Let me know if you need more info. Thanks

As a workaround, I changed all static class variables to standard class variable, and it fixed the problem. You probably do not fully support static class variables.

Moved to PLCnext Forum

Hello, this is a “special” behaviour of c++ regarding to static members. If a static member is declared in a class, this member has to be defined in the cpp file So just place the definition of you member variable in your cpp file this:

#include "NyxTimer.hpp"  
>   
> std::chrono::steady_clock::time_point NyxTimer::s_TimeRef;  
>   
>