AXC F 2152 Failed to load the library
Hello,
I am trying to run Forte (4diac run time written in C++) on AXC F F2152 assigned to a PLC task with PLCnext Engineer (2019.6). I was able to compile and execute it on AXC F 2152 directly calling the executable from Shell to check if we have made any mistake while compiling, so this means we are compiling it correctly.
We are also able to build the PLCnext library (.pcwlx), for Forte as well. Then we copied the PLCnext library to the PLCnext Engineer library and assigned to a PLC task, and downloaded to the PLC.
I was able to retrieve the log messages attached with this post as a doc file. So basically it is failing to load the libforte-shared.so which is our library build along with the PLCnext project.
My setup is as follows.
- plcncli version 2019.0 LTS
- SDK AXC F 2152, 2019.0.4 LTS
- Firmware 2019.04 LTS
- PLCnext Engineer 2019.6
- Eclipse IDE and PLCnext provided plugin.
- Forte Written in C++
Any help is welcome.
With Best Regards
Muddasir Shakil, M.Sc
Johannes kepler University, Linz
Austria
Comments
Hi Muddasir,
Firstly - that is a very interesting project you are working on. I was only saying recently that I wasn't aware of anyone having ported 4diac to a PLCnext Control, so I would be very interested to see the result of your work.
As for the error - it is promising that you were able to compile the 4diac runtime as an exe, and run it on the AXC F 2152.
Question 1:
You say that you "are also able to build the PLCnext library (.pcwlx), for Forte as well."
I don't understand what you mean by that. What steps did you take to include Forte in a PLCnext C++ Program, or C++ Component? Did you start from the plcncli C++ project template, and then add the Forte code into that? If so ... how?
The reason I ask is that there are a number of things that could cause the error you are seeing, e.g. the required methods not being implemented as expected in the C++ Component or Program.
Question 2:
A more general question about your project (if you don't mind) - What is the purpose of combining the 4diac runtime with a PLCnext Engineer project? Generally, the purpose of a Runtime (like Codesys or FourZero) is to provide an alternative to PLCnext Engineer, rather than providing an extension to PLCnext Engineer. These alternative runtimes usually access the PLC I/O directly - which I think is also possible with 4diac, by providing a platform-specific I/O driver - and so executing two runtimes on the PLC at the same time (e.g. PLCnext Engineer and Codesys) will create problems when both try to access the same physical I/O. It may be that there is no need to integrate 4diac into PLCnext Engineer - which would be another solution to this problem. :-)
If you are able to tell us more about your project objectives, then perhaps we can advise further.
Martin.
Thank you Martin for the interest, I will keep you in the loop about the progress.
Question 1:
We created a ForteComponent (PlcNext Component) and ForteIOhandler (PlcNext Program).
As for building the project, we did not start with plcncli c++ project template, instead we used the cmake toolchain file (axcf2152.cmake) to build the cmake project, provided by Björn Sauer. We used this file in a setup.sh file and also provide the installed Toolchain_Root (installed SDK) and ran the script. The script sets up the CMake project for forte and including all the cross compilers. In order to create a PLCnext library (.pcwlx) we added post build commands in a Cmake file where we tell Forte cmake project to add our ForteComponents,ForteComponentProgramProvider, ForteLibrary and ForteIOHandler source files. Here we basically give the path to EngineeringLibraryBuilder, which builds us the PlcNext library after building .so file. Using Cmake gui we configure generate.And compile everything in Eclipse.
I hope this answers your question1 :
Question 2:
4diac is an Event based execution environment unlike codesys. Yes you are right about having two run times on a PLC will cause problem.This project is more like an experimental and for demonstration purposes. We wanted to test out that how two different Run-times (Cyclic and Event based) can work together. As for demonstration we wanted to create a distributed control application using different PLCs (Open platform like yours). In 4diac you can model a distributed application rather easily.
With Best Regards
Muddasir
OK, I have just spoken with Björn and got some background on the build tools you are using.
It appears that the build tools (and the Component & Program code templates) that you are using are quite old, and probably not compatible with recent firmware versions. That would explain why the PLCnext runtime is having trouble loading the resulting library.
So, I recommend that you migrate your project to use the current PLCnext C++ project templates and build tools, using these steps:
- Create a new PLCnext C++ project in Eclipse, using the current version of the PLCnext plug-in (which I think you have installed already). This will create an "empty" C++ project for PLCnext with one Component and one Program - you can give these the names "ForteComponent" and "ForteIOhandler" to keep things consistent with the existing project, if you want.
- Copy the custom parts of your existing Component and Program into these new code skeletons.
- Build the project in Eclipse. This will automatically generate all the support C++ code and configuration files, then build the shared object library, and then package this as a PLCnext Engineer library (PCWLX file). You are free to edit the CMakeLists.txt file that is automatically created with the project, if you need to (for example) link to third-party libraries.
All going well, the resulting library should be loaded by the PLCnext runtime without any problems.
Martin.
Thank you for the reply.
You said "Build the project in Eclipse. This will automatically generate all the support C++ code and configuration files, then build the shared object library, and then package this as a PLCnext Engineer library (PCWLX file)."
Building the project in Eclipse would give me the packaged library (.pcwlx) file after which I cannot add the shared library (Forte shared library.so) with package because the library build is integrated with Eclipse plugin. Shouldn't I need to build the shared library (4diac run time lib) first and then include into my PLCnext C++ eclipse project? In some examples like OpenCV, they have transferred the shared libraries to PLC first and updated the symbolic links as well. Do you think I need to follow the similar approach. Like Build Forte as a shared library and transfer it to PLC first?
With BR
Muddasir Shakil
Hi Muddasir,
OK, so you are building and deploying another library (4diac runtime lib) with your PLCnext library. As you mentioned, there are various way to handle this situation - I normally deploy the other library separately, but I guess it may be possible to bundle it with the PLCnext Engineer library - I have never tried this myself, so I can't say how effective this is, or if this is the cause of the problem you are seeing. I would suggest that you first deploy everything to the PLC as simply as possible - even if this involves lots of manual steps - and when you have solved the problem you mentioned in the original post, you can work on streamlining the build and deployment process.
Hope this helps.
Martin.
Just looking at this again - in reference to this error in your log file:
... I had assumed that this is the library containing your PLCnext Engineer C++ component, but perhaps this is the "4diac runtime lib" that you referred to?
If so, then it looks like that might be the problem ... your own Component/Program refers to this library, but that library can't be found on the PLC. To check this quickly, you could try:
libforte-shared.so
file to the PLC directory/usr/local/lib
sudo ldconfig
... then restart the PLCnext runtime. If this error disappears, then that was the problem.
If this fixes the problem, then I suggest that you do not package that .so file with the PLCnext Engineer library, but rather install it on the PLC separately.
Martin.