# Compiling OpenCN on Debian12

**URL:** <http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397>\
**Category:** OpenCN Framework\
**Created:** [July 13, 2023, 6:46am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397 "2023-07-13T06:46:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasi](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vasi](http://discourse.heig-vd.ch/u/vasi)\
**Post date:** [July 13, 2023, 6:46am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/1 "2023-07-13T06:46:57Z")

</div>

Hi guys,

I recently upgraded to Debian 12 as I needed the latest version of GRPC for my linuxcnc project.  
I’ve made the update by changing the repositories all my previous setup remained in place.  
I tried again to recompile OpenCN, so I pulled the latest master and tried to run the commands described here: [8. User guide — OpenCN 2021.2.0 documentation](https://mecatronyx.gitlab.io/opencnc/opencn/user_guide.html)  
I have pasted into a file the messages that I get in the console.

```auto
➜ opencn git:(master) ✗ sudo apt install bc bison bridge-utils ca-certificates capnproto cpio \
  cmake device-tree-compiler default-jdk dosfstools dvipng elfutils fakeroot file flex \
  gcc git graphviz g++ latexmk lib32z1-dev libc6:i386 libcapnp-dev libcapstone3 libepoxy0 \
  libgbm1 libgtk2.0-dev libjpeg62 libssl-dev libstdc++6:i386 libusb-1.0-0 make nano \
  openssh-server patch pkg-config python3 python3-pip python3-crypto python3-pyelftools \
  rsync sudo tex-gyre texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended \
  wget unzip u-boot-tools xz-utils zlib1g:i386
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'libjpeg62-turbo' instead of 'liabjpeg62'
Package python3-crypto is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Unable to locate package libcapstone3
E: Package 'python3-crypto' has no installation candidate
➜ opencn git:(master) ✗ 

Not found: libcapstone3, python3-crypto

➜ / cd ~/Work/opencn/agency 
➜ agency git:(master) ✗ ./build.sh -t x86
➜ agency git:(master) ✗ ./build.sh -a
read target from the file
-- [Build Linux kernel] ----------------------------------
LINUX_CONF=x86_defconfig
---------------------------------------------[BUILDING linux]---
make -C linux x86_defconfig || exit -1
make[1]: Entering directory '/home/vasimihalca/Work/opencn/agency/linux'
#
# No change to .config
#
make[1]: Leaving directory '/home/vasimihalca/Work/opencn/agency/linux'
make -C linux -rR --no-print-directory bzImage -j$(nproc) || exit -1
  DESCEND objtool
  CALL scripts/atomic/check-atomics.sh
  CALL scripts/checksyscalls.sh
  CC /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/help.o
  CC /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/sigchain.o
In file included from sigchain.c:3:
In function ‘xrealloc’,
    inlined from ‘sigchain_push.isra’ at sigchain.c:26:2:
subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   56 | ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 | void *ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   58 | ret = realloc(ptr, 1);
      | ^ ~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 | void *ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
In function ‘xrealloc’,
    inlined from ‘sigchain_push’ at sigchain.c:26:2,
    inlined from ‘sigchain_push_common’ at sigchain.c:53:2:
subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   56 | ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 | void *ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   58 | ret = realloc(ptr, 1);
      | ^ ~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 | void *ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
mv: cannot stat '/home/vasimihalca/Work/opencn/agency/linux/tools/objtool/.sigchain.o.tmp': No such file or directory
make[5]: *** [/home/vasimihalca/Work/opencn/agency/linux/tools/build/Makefile.build:96: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/sigchain.o] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from help.c:12:
In function ‘xrealloc’,
    inlined from ‘add_cmdname’ at help.c:24:2:
subcmd-util.h:56:23: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   56 | ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 | void *ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
   58 | ret = realloc(ptr, 1);
      | ^ ~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to ‘realloc’ here
   52 | void *ret = realloc(ptr, size);
      | ^ ~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
mv: cannot stat '/home/vasimihalca/Work/opencn/agency/linux/tools/objtool/.help.o.tmp': No such file or directory
make[5]: *** [/home/vasimihalca/Work/opencn/agency/linux/tools/build/Makefile.build:96: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/help.o] Error 1
make[4]: *** [Makefile:58: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/libsubcmd-in.o] Error 2
make[3]: *** [Makefile:54: /home/vasimihalca/Work/opencn/agency/linux/tools/objtool/libsubcmd.a] Error 2
make[2]: *** [Makefile:67: objtool] Error 2
make[1]: *** [Makefile:1850: tools/objtool] Error 2
make: *** [Makefile:73: agency_x86_domain] Error 255

[ERROR] kernel compilation failed !!
➜ agency git:(master) ✗ 

```

Please provide any hints on what to do next to unblock myself.

Thanks,  
Vasi Mihalca

---

<div class="post-metadata">

**Author:** ![jmi](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/jmi/32/125_2.png) [@jmi](http://discourse.heig-vd.ch/u/jmi)\
**Post date:** [July 13, 2023, 7:26am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/2 "2023-07-13T07:26:27Z")

</div>

Hi Vasi,

It seems that some packages where not installed. Can you tried to install `python3-cryptography` and `libcapstone4` packages ?

To avoid the environment errors, can can also use the docker image for the compilation.

Hope this helps  
J/P

---

<div class="post-metadata">

**Author:** ![jmi](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/jmi/32/125_2.png) [@jmi](http://discourse.heig-vd.ch/u/jmi)\
**Post date:** [July 13, 2023, 7:36am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/3 "2023-07-13T07:36:59Z")

</div>

2 small comments:

- The installation guide was tested on Ubuntu 20.04
- My personal machine runs Debian 12 🙂

---

<div class="post-metadata">

**Author:** ![vasi](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vasi](http://discourse.heig-vd.ch/u/vasi)\
**Post date:** [July 13, 2023, 9:26am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/4 "2023-07-13T09:26:44Z")

</div>

I have those packages installed, and still the same error.  
I tried using docker and I run into a different error. Here is what I encounter with docker:

> **[OpenCN Docker issues - Pastebin.com](https://pastebin.com/L4QKBiPE)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

I had to use pastebin because the code block was limited as number of characters and I wanted to add all the console log.

---

<div class="post-metadata">

**Author:** ![jmi](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/jmi/32/125_2.png) [@jmi](http://discourse.heig-vd.ch/u/jmi)\
**Post date:** [July 13, 2023, 9:58am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/5 "2023-07-13T09:58:51Z")

</div>

It seems you have issue with your docker. There is the following error in the log you shared:

> docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create”: dial unix /var/run/docker.sock: connect: permission denied.

I think you should add you usr in docker group to avoid having to use `sudo` ([doc](https://docs.docker.com/engine/install/linux-postinstall/)),

Just to be 100% can you try the following cmd:

```auto
docker run hello-world

```

If It works, next debug phase is to build and run OpenCN image and try to log, with ssh into it. You have the doc: docker/README

For the native compilation, can you try with another target, x86-qemu, instead of x86 ?

Hope this helps  
J-P

---

<div class="post-metadata">

**Author:** ![vasi](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vasi](http://discourse.heig-vd.ch/u/vasi)\
**Post date:** [July 13, 2023, 11:05am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/6 "2023-07-13T11:05:58Z")

</div>

I have added the user in the docker group, so now I can run the docker without sudo. However, I still have some issues: [OpenCN Docker Issues 2 - Pastebin.com](https://pastebin.com/4bGUKjdp)

Thanks for your prompt answer!

---

<div class="post-metadata">

**Author:** ![jmi](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/jmi/32/125_2.png) [@jmi](http://discourse.heig-vd.ch/u/jmi)\
**Post date:** [July 13, 2023, 12:47pm UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/7 "2023-07-13T12:47:27Z")

</div>

Can you try the build cmd without the `sudo` ?

---

<div class="post-metadata">

**Author:** ![jmi](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/jmi/32/125_2.png) [@jmi](http://discourse.heig-vd.ch/u/jmi)\
**Post date:** [July 13, 2023, 12:54pm UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/8 "2023-07-13T12:54:51Z")

</div>

Sorry, I answered to quickly.

It seems that the build error arrived during rootfs build. Can you try the following cmd:

```auto
./build.sh -rc
./build.sh -r

```

It cleans and restarts the build process of the rootfs part of OpenCN.

---

<div class="post-metadata">

**Author:** ![vasi](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vasi](http://discourse.heig-vd.ch/u/vasi)\
**Post date:** [July 14, 2023, 7:57am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/9 "2023-07-14T07:57:11Z")

</div>

I was able to get the server running, I get the following

```auto
Starting OpenCN server
/
OK
/root/start_opencn.sh: line 13: /root/opencn-m5-server: No such file or directoy
Starting sshd: OK

opencn ~ # [5.026126] e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flx
[5.027768] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

```

Then I tried to build the host and got the following result:

```auto
[98%] Linking CXX executable user-m5-gui
[98%] Built target user-m5-gui
[98%] Linking CXX executable user-gui
[98%] Built target user-gui
make: *** [Makefile:91: all] Error 2
/home/vasimihalca/Work/opencn/agency/usr
Copy build-host/host/user_gui/user-gui
Copy build-host/host/user_m5_gui/user-m5-gui
Copy host/tooledit/tooledit.sh
➜ usr git:(master) ✗ 

```

Not sure if that “Error 2” is relevant, but when I try to run the ./user-gui I get a popup that has the following IP: 192.168.53.15 Port: 7001, and when I click ok nothing happens.  
Not sure if the IP is correct or how did it come to this IP

This is what I see in the console:

```auto
➜ user_gui git:(master) ✗ ./user-gui
Using qt version: 5.15.8
QSocketNotifier: Can only be used with threads started with QThread
QMetaObject::connectSlotsByName: No matching signal for on_space_pressed()
QMetaObject::connectSlotsByName: No matching signal for on_push_gcoderefresh_clicked()
RpcClientQTIntf done 

```

Thanks for all your replies so far!

---

<div class="post-metadata">

**Author:** ![jmi](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/jmi/32/125_2.png) [@jmi](http://discourse.heig-vd.ch/u/jmi)\
**Post date:** [July 14, 2023, 2:54pm UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/10 "2023-07-14T14:54:15Z")

</div>

Great that you have been able to start OpenCN. It is emulation or native (x86 - rpi4) ?

You arrived at the place where the issue starts (our doc lacks info).

So starting from the beginning:

- On which branch are you ? I saw the following error which is not expected to happen form master

```auto
/root/start_opencn.sh: line 13: /root/opencn-m5-server: No such file or directory

```

- The error during the build process may be an issue. It depends where it was generated. As you have the `usr-gui` and `usr-m5-gui` maybe not important in current situation

- The application and the target communicate through IP. The target has an hardcoded IP ( `192.168.53.15`). Can you check if a ping between target and host is working ?

Hope this helps

---

<div class="post-metadata">

**Author:** ![Xavier](http://discourse.heig-vd.ch/user_avatar/discourse.heig-vd.ch/xavier/32/91_2.png) [@Xavier](http://discourse.heig-vd.ch/u/Xavier)\
**Post date:** [August 11, 2023, 6:58am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/11 "2023-08-11T06:58:09Z")

</div>

Hi @vasi,

Sorry to see you had that much trouble to run OpenCN.

What is your current status ? Were you able to make it run with the GUI ?

Soltner Xavier

---

<div class="post-metadata">

**Author:** ![vasi](http://discourse.heig-vd.ch/letter_avatar_proxy/v4/letter/v/a4c791/32.png) [@vasi](http://discourse.heig-vd.ch/u/vasi)\
**Post date:** [August 23, 2023, 8:17am UTC](http://discourse.heig-vd.ch/t/compiling-opencn-on-debian12/397/12 "2023-08-23T08:17:45Z")

</div>

Hi @Xavier @jmi  
I was kinda offline in the last month so I did not tried to run it anymore.  
I saw the PR that added new functionalities to halcmd, looked over it but it was mostly c/c++ so didn’t had something relevant to say on that PR.

The last issue that I remember while trying to run the client was smth related to LD\_LIBRARY\_PATH, but before we start debugging it again I will pull the latest sources and try to rebuild again.

Will come back with the result.

Thanks for your support,  
Vasi Mihalca
