cerci98
I have installed OpenPLC on my MacBook pro 2017 ( intel processor). I'm using the software in a docker container. When I try to upload a new program (I've tried several program) the output is always:
Optimizing ST program...
./scripts/compile_program.sh: line 19: ./st_optimizer: cannot execute binary file: Exec format error
Generating C files...
./scripts/compile_program.sh: line 21: ./iec2c: cannot execute binary file: Exec format error
Error generating C files
Compilation finished with errors!
I've do some research and seems to be a problem with the gcc compiler on my pc, that is not compatible with the executable st_optimizer and iec2c. I've already searched for the .c files, to create the executable file myself, but on github they aren't updated from 5 years ago.Someone knows how to solve this problem or what gcc compiler i have to use for not receive this error?
Thank You.
Reply 0 0
thiagoralves
These files are compiled during OpenPLC installation. It is probably not related to your gcc version, but to the fact that you might be using a prebuilt binary from a different architecture. Check lines 67 onward of the installer script here to see how these files are compiled. Ideally, you should run the full installer in your docker container, otherwise you might have other hiccups in the process.
Reply 0 0
cerci98
I created a container with a debian linux OS, then i have installed the OpenPLC v3 by using the ./ install.sh linux command, but now i can't reboot the operating system inside the container without restart the container. Even in this case the server is not running.
Reply 0 0
thiagoralves
Do you really need to use docker? For beginners a simple Debian VM on Virtualbox usually works great.
Reply 0 0
cerci98
I followed your advice and now i'm using a debian virtual machine. It's working great. Thank you
Reply 0 0
Atlas192
Hi,
is there a solution for the docker container?

i did run the docker build command from https://github.com/thiagoralves/OpenPLC_v3
but still i get the following issues when uploading a program:
 
cat: ethercat: No such file or directory
Optimizing ST program...
./st_optimizer: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./st_optimizer)
./st_optimizer: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by ./st_optimizer)
./st_optimizer: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./st_optimizer)
Generating C files...
./iec2c: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./iec2c)
./iec2c: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by ./iec2c)
./iec2c: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./iec2c)
Error generating C files
Compilation finished with errors!
Reply 0 0
Atlas192
Hi,

so i have found a (sort of) solution for this problem.

to get rid of the missing "GLIBC_2.34" package  i used the latest ubuntu:22.04 instead of debian.
Just change the first line inside the dockerfile before you run the build script.
 
The two "GLIBCXX_3.4.32" and "GLIBCXX_3.4.29" packages were a bit more tricky.
 
First i used docker desktop to get terminal access to the root user of the ubuntu containe. I assume SSH would also work, but this was the easiest solution for me.
Then you need to add the toolchain repository.
apt-get install software-properties-common
add-apt-repository ppa:ubuntu-toolchain-r/test
apt update
when the repository is installed you should be able to install the missing GLIBCXX
apt-get install libstdc++6
 
 
Now i was able to "compile" the .st file but there are still some missing packages.
cat: ethercat: No such file or directory
Optimizing ST program...
Generating C files...
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Config0.c
Config0.h
Res0.c
Moving Files...
Compiling for Linux
Generating object files...
Generating glueVars...
Compiling main program...
Package libmodbus was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmodbus.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libmodbus' found
dnp3.cpp:5:10: fatal error: asiodnp3/DNP3Manager.h: No such file or directory
5 | #include <asiodnp3/DNP3Manager.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
modbus_master.cpp:31:10: fatal error: modbus.h: No such file or directory
31 | #include <modbus.h>
| ^~~~~~~~~~
compilation terminated.
Error compiling C files
Compilation finished with errors!
Reply 0 0
Atlas192
so I already had the solution the last time. Just need to do the stuff in the right order.
 
as stated above you change the first line on the Dockerfile to:

FROM ubuntu:22.04
 
then you also need to insert the below mentioned lines between the line 48 and 49 of the background-installer.sh:
 
$1 apt-get install software-properties-common
$1 add-apt-repository ppa:ubuntu-toolchain-r/test
$1 apt-get update
$1 apt-get install libstdc++6
Reply 0 0
Reply