Tag Archives: Embedded Linux

[Solved] Linux Compile Error: error: ‘for’ loop initial declarations are only allowed in C99 mode

1. Problem description

During the development of embedded Linux, compile and report the following errors

src/util/Vector.c:94:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
         for (int j = V->length++; j > i; j--)
         ^
src/util/Vector.c:94:9: note: use option -std=c99 or -std=gnu99 to compile your code
src/util/Vector.c: In function ‘Vector_remove’:
src/util/Vector.c:123:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
         for (int j = i; j < V->length; j++)
         ^

2. Problem analysis

GCC compilation is based on compilation lower than C99 standard. Defining variables within a for loop is not allowed in standards lower than C99.

3. Solution

Method 1

Modify code

int j;
for (j = i; j < V->length; j++)

Method 2

GCC specifies compiling using the C99 standard

gcc -std=c99

Method 3

Specify the C99 standard for compilation in makefile

CFLAGS += -std=c99

[Solved] sys.stderr.write(f“ERROR: {exc}“) SyntaxError: invalid syntax

There was an error querying the version of Ubuntu after installing PIP3

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 57
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Solution:

wget https://bootstrap.pypa.io/pip/3.5/get-pip.py

After downloading, execute the following command

python3 get-pip.py 

[Solved] Linux Kernel Compile Error: make menuconfig‘ requires the ncurses libraries

report errors

*** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
make[1]: *** [scripts/kconfig/Makefile:202: scripts/kconfig/dochecklxdialog] Error 1
make: *** [Makefile:520: menuconfig] Error 2

Solution:
sudo apt-get install libncurses5-dev

error while loading shared libraries: libz.so.1 [How to Solve]

Error in compiling Quanzhi Linux kernel

  CC      scripts/mod/empty.o
  HOSTCC  scripts/genksyms/genksyms.o
  SHIPPED scripts/genksyms/lex.lex.c
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/mod/mk_elfconfig
  HOSTCC  scripts/recordmcount
  SHIPPED scripts/genksyms/keywords.hash.c
/home/ql/linux/H3Core/lichee/out/sun8iw7p1/dragonboard/common/buildroot/external-toolchain/bin/../libexec/gcc/arm-linux-gnueabi/4.6.3/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make[2]: *** [scripts/Makefile.build:308:scripts/mod/empty.o] error 1
make[2]: *** Waiting for unfinished tasks...
  SHIPPED scripts/genksyms/parse.tab.h
  SHIPPED scripts/genksyms/parse.tab.c
  HOSTCC  scripts/genksyms/lex.lex.o
  HOSTCC  scripts/genksyms/parse.tab.o
make[1]: *** [scripts/Makefile.build:443:scripts/mod] error 2
make[1]: *** Waiting for unfinished tasks...
  CC      kernel/bounds.s
/home/ql/linux/H3Core/lichee/out/sun8iw7p1/dragonboard/common/buildroot/external-toolchain/bin/../libexec/gcc/arm-linux-gnueabi/4.6.3/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make[1]: *** [/home/ql/linux/H3Core/lichee/linux-3.4/./Kbuild:36:kernel/bounds.s] 错误 1
make: *** [Makefile:985:prepare0] error 2
make: *** Waiting for unfinished tasks...
  HOSTLD  scripts/genksyms/genksyms
make: *** [Makefile:506:scripts] error 2

Execute the following instructions to install the library
sudo apt get install lib32z1

[Solved] Ubuntu Update source error: Certificate verification failed: The certificate is NOT trusted.

Updating the Ubuntu source today always reports an error

Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Ign:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal Release
  Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate.  Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates Release
  Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate.  Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports Release
  Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate.  Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Err:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security Release
  Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate.  Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Reading package lists... Done
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Finally, refer to the method of online leaders, change HTTPS in the software source to HTTP, and solve it successfully.

# The source image is commented by default to improve the speed of apt update, you can uncomment it if needed
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse