I tried to follow this Tutorial to create a shared native Project with some functionblocks.
Upon executing plcncli generate code i got an error message:
Project information could not be fetched from csharp project. See log for details.
I looked for errors in the Logfiles at ~/.config/plcncli/logs/cli/LogFiles and found:
plcncli Information: 0 : 25/06/2025 09:11:37.219: INFORMATION: [dotnet]: /.../...CSharp.csproj(100,5): error : PLCnext toolchain is not installed correctly. 'PLCnext.targets' file is missing. Reinstall the toolchain!
A reinstall of the toolchain did not fix the problem. I searched for the missing file and it was located at (the presumably correct location) <plcncli install dir>/eCRL/PLCnext.targets.
This made me wonder, so i took an strace of the program to find it tries to open the absolute(!) path /eCLR/PLCnext.targets. After copying the eCLR dir to / the files were no longer missing.
The toolchain I am using is plcncli 25.0.0.5997 (25.0.0.5997).
It seems even after applying the fix, there is still something wrong. The command plcncli generate code does not generate any c++ files in the src directory. This is the output:
$ plcncli generate code
Generating all files with the 'code' generator for /home/<USER>/MyFBProject/MyFBProjectCpp.
[dotnet]: MSBuild version 17.8.27+3ab07f0cf for .NET
[dotnet]: Build started 6/25/2025 11:48:29 AM.
[dotnet]: 1>Project "/home/<USER>/MyFBProject/MyFBProjectCSharp/MyFBProjectCSharp.csproj" on node 1 (default targets).
[dotnet]: 1>PrepareForBuild:
[dotnet]: Creating directory "Cli/".
[dotnet]: Creating directory "obj/Release/".
[dotnet]: ResolveAssemblyReferences:
[dotnet]: A TargetFramework profile exclusion list will be generated.
[dotnet]: CoreCompile:
[dotnet]: /usr/lib/dotnet/dotnet exec "/usr/lib/dotnet/sdk/8.0.117/Roslyn/bincore/csc.dll" /noconfig /unsafe+ /nowarn:1701,1702 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentropyva- /reference:/eCLR/v3.4.0/eclrlib.dll /reference:/eCLR/v3.4.0/IecEngineering.dll /reference:/eCLR/v3.4.0/mscorlib.dll /reference:/eCLR/v3.4.0/pcoslib.dll /debug:pdbonly /filealign:512 /optimize+ /out:obj/Release/MyFBProject.dll /target:library /utf8output /langversion:7.3 Properties/AssemblyInfo.cs MyFirstFB.cs "obj/Release/.NETFramework,Version=v4.0,Profile=eCLR3.4.AssemblyAttributes.cs"
[dotnet]: CompilerServer: server - server processed compilation - 15b44223-c493-42fb-8c95-9d654f82fb8b
[dotnet]: _CopyFilesMarkedCopyLocal:
[dotnet]: Copying file from "/eCLR/v3.4.0/pcoslib.dll" to "/home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/pcoslib.dll".
[dotnet]: Copying file from "/eCLR/v3.4.0/IecEngineering.dll" to "/home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/IecEngineering.dll".
[dotnet]: Copying file from "/eCLR/v3.4.0/eclrlib.dll" to "/home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/eclrlib.dll".
[dotnet]: Copying file from "/eCLR/v3.4.0/mscorlib.dll" to "/home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/mscorlib.dll".
[dotnet]: Creating "/home/<USER>/MyFBProject/MyFBProjectCSharp/obj/Release/MyFBProjectCSharp.csproj.CopyComplete" because "AlwaysCreate" was specified.
[dotnet]: Touching "/home/<USER>/MyFBProject/MyFBProjectCSharp/obj/Release/MyFBProjectCSharp.csproj.CopyComplete".
[dotnet]: CopyFilesToOutputDirectory:
[dotnet]: Copying file from "/home/<USER>/MyFBProject/MyFBProjectCSharp/obj/Release/MyFBProject.dll" to "/home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/MyFBProject.dll".
[dotnet]: MyFBProjectCSharp -> /home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/MyFBProject.dll
[dotnet]: Copying file from "/home/<USER>/MyFBProject/MyFBProjectCSharp/obj/Release/MyFBProject.pdb" to "/home/<USER>/MyFBProject/MyFBProjectCSharp/Cli/MyFBProject.pdb".
[dotnet]: 1>Done Building Project "/home/<USER>/MyFBProject/MyFBProjectCSharp/MyFBProjectCSharp.csproj" (default targets).
[dotnet]:
[dotnet]: Build succeeded.
[dotnet]: 0 Warning(s)
[dotnet]: 0 Error(s)
[dotnet]:
[dotnet]: Time Elapsed 00:00:00.46
[cmake]: CMake Error: Cannot determine link language for target "MyFBProject".
[cmake]: CMake Error: CMake can not determine linker language for target: MyFBProject
[cmake]: CMake Generate step failed. Build files cannot be regenerated correctly.
[cmake]: -- Configuring done (0.0s)
[cmake]: CMake Error: Cannot determine link language for target "MyFBProject".
[cmake]: CMake Error: CMake can not determine linker language for target: MyFBProject
[cmake]: -- Generating done (0.0s)
[cmake]: CMake Generate step failed. Build files cannot be regenerated correctly.
Successfully generated all files with the 'code' generator for /home/<USER>/MyFBProject/MyFBProjectCpp.
Any clues on what the problem could be?
Hello,
i believe no target was added to the toolchain yet or it needs to be added again after reinstalling the Toolchain.
And then add the target to this project. Shared native libraries need to be explicitly build for each specfic target.
See also:
Functions and functions blocks
e.g.
$ plcncli.exe new snproject -n „Proj“
Successfully created template ‚snproject‘ in SNT\Proj.
$ cd Proj/
$ cd ProjCpp/
$ plcncli.exe set target --add -n axcf2152 -v 2025.0
Successfully added target AXCF2152 2025.0.2 (25.0.2.92) to project SNT\Proj\ProjCpp.
$ plcncli.exe new snfunctionblock -n MyFB
Successfully created template ‚snfunctionblock‘ in SNT\Proj\ProjCSharp.
$ plcncli.exe generate code
…
Successfully generated all files with the ‚code‘ generator for SNT\Proj\ProjCpp.
$ plcncli.exe build all
Finished build for all targets
$ plcncli.exe deploy
Successfully deployed all files for SNT\Proj\ProjCpp.
$ ls -la bin/Proj.pcwlx
bin/Proj.pcwlx
Managing SDKs
e.g. Installing a Target SDK:
plcncli.exe install sdk -d „/c/SDK/AXCF2152/2025.0.2.92“ -p ~/Downloads/axcf2152-mingw_sdk-2025.0.2-25.0.2.92.tar.xz/axcf2152-mingw_sdk-2025.0.2-25.0.2.92.tar.xz
I have followed the tutorial and added a target to the project:
$ plcncli new snproject -n "MyFBProject"
Successfully created template 'snproject' in /home/<USER>/MyFBProject.
$ cd MyFBProject/MyFBProjectCpp
$ plcncli set target --add -n axcf2152 -v 2023.0
Successfully added target AXCF2152 2023.0.0 LTS (23.0.0.65) to project /home/<USER>/MyFBProject/MyFBProjectCpp.
$ plcncli new snfunctionblock -n "MyFirstFB"
Successfully created template 'snfunctionblock' in /home/<USER>/MyFBProject/MyFBProjectCSharp.
$ plcncli generate code
<see above>
I have installed the SDK 2023.0 after reinstalling the toolchain.
I now installed the Toolchain, SDK and BuildTools on Windows and now the files are generated correctly.
After the files are generated, I can use the command plcncli build all to build the project on Linux correctly, but the command plcncli deploy fails:
$ plcncli deploy
[cmake]: -- Configuring done (0.0s)
[cmake]: -- Generating done (0.0s)
[cmake]: -- Build files have been written to: /home/<USER>/MyFBProject/MyFBProjectCpp/intermediate/cmake/AXCF2152,22.6.0.43/Release
No library file was found in the path '/home/<USER>/MyFBProject/MyFBProjectCpp/bin/Common/MyFBProject.dll'.
On Windows it works as intended.
I am sorry, the Known issue Section in the Changelog mentions this issue.
Shared Native Projects are not fully supported in Linux. Generating new shared native projects with Linux is not possible because the interface generator is only build for Windows. Minimum the generate step has to run on a windows system. We are working on a rework to also support linux, but I can’t give a timepoint.
Ok, thanks for the information.