Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Classes within or outside of CPLCs
#1
How do I go about creating a C/C++ class within a CPLC/Capp, or in a separate class that I can call from a CPLC/Capp? I don't see the option in the Power PMAC IDE to add a "class" file to the project.

I've tried adding the most basic class to a CPLC:

class TestClass {

};


But it reports a syntax error, and will not compile. I'm not sure why it will not compile, as this is standard C++ syntax.
Reply
#2
I think I have answered my own question...

It seems that CPLC's can be written only in C, not C++. For some reason one of my Delta Tau programming PDFs indicates that CPLC's can be written in C++. It looks like that is either not the case, or it has not been implemented yet.
Reply
#3
PowerPMAC/ IDE project system only support C language and not c++.
Atul
(07-27-2010, 04:30 PM)shansen Wrote: I think I have answered my own question...

It seems that CPLC's can be written only in C, not C++. For some reason one of my Delta Tau programming PDFs indicates that CPLC's can be written in C++. It looks like that is either not the case, or it has not been implemented yet.
Reply
#4
What about compiling C++ outside of the PMAC IDE system (i.e. at the Linux command prompt)? For example, I created the following file (hello.cpp) as an experiment:

Code:
#include <iostream>
#include "gplib.h"
#include "RtGpShm.h"

using namespace std;

int main()
{
    cout << "Hello World!" << endl;

    InitLibrary();

    while(true)
    {
        cout
        << pshm->ServoTime << ","
        << pshm->Motor[5].DesPos << ","
        << pshm->Motor[5].ActPos << endl;
    }

    return 0;
}

I can compile/link it using the following command:

g++ -I /opt/ppmac/libppmac -I /opt/ppmac/rtpmac -L /opt/ppmac/libppmac -l ppmac -l rt hello.cpp -o hello

However, I get an error when I run hello:

error while loading shared libraries: libppmac.so

Running "ldd hello" confirms that the library is not found, but I have not been able to resolve the error. If I comment out the InitLibrary() command, I can run the program, but the initialization of pshm has not been done so the program crashes.

Does anyone know how to resolve the libppmac.so issue?

Also, is there any plan to allow C++ code within the IDE?
Reply
#5
I figured it out. It compiles and links properly with the following command:

g++ -I /opt/ppmac/libppmac -I /opt/ppmac/rtpmac -L /opt/ppmac/libppmac -l ppmac -l rt -Wl,-R/opt/ppmac/libppmac hello.cpp -o hello
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)