This site uses cookies for functional purposes. To continue please read and agree to our Data Privacy.

By closing this message, you consent to our use of cookies on this device.

PLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. David Petter
  2. PLCnext Technology & PLCnext Controls
  3. Tuesday, 03 April 2018
  4.  Subscribe via email

Hey everyone.


Maybe I misread some of the documentation, but I cannot seem to find any info on how to write a c++ program for the PLCNext using additional libraries.

In a "normal" programming environment, when I write a c++ program, I would simply make the #include at the top of the program.
Immediately below it, I would write the "using namespace" etc. for that library.
I am writing some software using the OpenCV library, which I have tested on a Windows machine, the code has a 'normal' lay-out, like this:


#include "stdio"
#include "opencv/core/core.hpp"

using namespace cv;

int main (int argc, char** argv){

//Execution here



However, now that I am ready to use (re-write) this code for an AXCF2152, I can not simply use the "using namespace" syntax, because writing software for this target has to be done inside the library, example:

namespace Library { namespace component {
// port info here

void program::execute(){
//execution here

How do I go about using the namespaces from an imported library in an AXCF2152 program? I did not have any success adding them in the header file, or I made a mistake doing that...

It would be greatly appreceated if anyone has some documentation or tips as to how this is done...







Accepted Answer
Vincent PLCnext Team Accepted Answer Pending Moderation

Hi David,


Using namespaces is exactly the same as in regular C++ (as it is regular C++).

Given this class 'Benchmark' (cpp):

#include "Benchmark.h"
namespace NL_PXC {
namespace UTIL {

using namespace std::chrono;

for example the verbose way is would be

  NL_PXC::UTIL::Benchmark *bm;// = new Benchmark(5);


 the more compact means would be:



#include "../util/Benchmark.h"

namespace NL_PXC { namespace Example_Database {

using namespace Arp;
using namespace Arp::Plc::Esm;
using namespace NL_PXC::UTIL;

class MyDatabaseProgram : public ProgramBase, private Loggable
public: // typedefs

public: // construction/destruction
    MyDatabaseProgram(const String& name);
    MyDatabaseProgram(const MyDatabaseProgram& arg) = delete;
    virtual ~MyDatabaseProgram(void) = default;

public: // operators
    MyDatabaseProgram&  operator=(const MyDatabaseProgram& arg) = delete;

public: // properties

public: // operations
    void    Execute(void)override;

private: // fields

   Benchmark *bm;// = new Benchmark(5);

Phoenix Contact Netherlands - Technical Consultant

David Petter Accepted Answer Pending Moderation

That seems to work just dandy.

Thank you.



  • Page :
  • 1

There are no replies made for this post yet.
However, you are not allowed to reply to this post.