CMake error: The C compiler is not able to compile a simple test program.

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

CMake error: The C compiler is not able to compile a simple test program.

Postby RobertHeller » Sat Jun 25, 2022 4:01 pm

I am getting a CMake error when I do 'idf.py set-target esp32'. What am I doing wrong?

CMakeError.log:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Build flags: -mlongcalls;-Wno-frame-address
Id flags:

The output was:
1
/home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: error loading plugin: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: cannot open shared object file: No such file or directory
collect2: error: ld returned 1 exit status


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++
Build flags: -mlongcalls;-Wno-frame-address
Id flags:

The output was:
1
/home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: error loading plugin: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: cannot open shared object file: No such file or directory
collect2: error: ld returned 1 exit status


Determining if the C compiler works failed with the following output:
Change Dir: /home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_c017e/fast && /usr/bin/make -f CMakeFiles/cmTC_c017e.dir/build.make CMakeFiles/cmTC_c017e.dir/build
make[1]: Entering directory '/home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_c017e.dir/testCCompiler.c.obj
/home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_c017e.dir/testCCompiler.c.obj -c /home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_c017e
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c017e.dir/link.txt --verbose=1
/home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address CMakeFiles/cmTC_c017e.dir/testCCompiler.c.obj -o cmTC_c017e
/home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: error loading plugin: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: cannot open shared object file: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_c017e.dir/build.make:87: cmTC_c017e] Error 1
make[1]: Leaving directory '/home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_c017e/fast] Error 2

CMakeOutput.log:
The target system is: Generic - -
The host system is: Linux - 5.10.103-v7l+ - armv7l
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Build flags: -mlongcalls;-Wno-frame-address
Id flags: -c

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"

The C compiler identification is GNU, found in "/home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/3.16.3/CompilerIdC/CMakeCCompilerId.o"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /home/heller/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++
Build flags: -mlongcalls;-Wno-frame-address
Id flags: -c

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o"

The CXX compiler identification is GNU, found in "/home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.o"

Checking whether the ASM compiler is GNU using "--version" matched "(GNU assembler)|(GCC)|(Free Software Foundation)":
xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

About my previous post able CMake failing...

Postby RobertHeller » Sat Jun 25, 2022 6:42 pm

The problem seems to be be scpecific to my Raspberry Pi. The same code works on an x86_64 host. (And yes, I did install the ARM host build toolchain on the Raspberry Pi.)

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby RobertHeller » Sun Jun 26, 2022 1:38 am

This problem seems to be specificly with a Raspberry Pi as the host. I *think* it might be a arch. error -- The toolchain seem to be for a different ARM Linux system than the Raspberry Pi. I am using a Pi 4:

fruitloops% objdump -x .espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so|head

.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so: file format elf32-littlearm
.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/libexec/gcc/xtensa-esp32-elf/8.4.0/liblto_plugin.so
architecture: armv4t, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00002420

Program Header:
LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**16
filesz 0x0001099c memsz 0x0001099c flags r-x
fruitloops%

fruitloops% objdump -x /usr/lib/arm-linux-gnueabihf/libstdc++.so.6|head

/usr/lib/arm-linux-gnueabihf/libstdc++.so.6: file format elf32-littlearm
/usr/lib/arm-linux-gnueabihf/libstdc++.so.6
architecture: arm, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x0006e340

Program Header:
0x70000001 off 0x00129780 vaddr 0x00129780 paddr 0x00129780 align 2**2
filesz 0x00004270 memsz 0x00004270 flags r--
fruitloops% fruitloops% cat /etc/issue
Raspbian GNU/Linux 10 \n \l

fruitloops% uname -a
Linux fruitloops 5.10.103-v7l+ #1529 SMP Tue Mar 8 12:24:00 GMT 2022 armv7l GNU/Linux
fruitloops% cat /proc/cpu
cpu/ cpuinfo
fruitloops% head /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 108.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3

fruitloops%

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby ESP_Sprite » Sun Jun 26, 2022 2:31 am

What esp-idf version is this? Can you try updating to the master branch to see if this is still an issue?

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby RobertHeller » Sun Jun 26, 2022 8:36 pm

I am using 4.4.1. I am not sure if the main third-party component I am using (OpenMRNIDF) will work correctly with a newer version of the IDF.

My project compiles just fine with 4.4.1 on my x86_64 Ubuntu 18.04 machine. The problem is the Rasperry Pi 4 is my workbench machine, and I would like to use it as the machine I flash my projects.

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby RobertHeller » Tue Jun 28, 2022 6:29 pm

OK, I tried to install from the master branch, but things fail in install.sh:

After installing the newer compilers, I get this error:

Installing Python environment and packages
ERROR: This script was called from a virtual environment, can not create a virtual environment again

Which makes no sense.

I guess the answer seems to be that the esp-idf does not work with a Raspberry Pi host...

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby RobertHeller » Tue Jun 28, 2022 8:08 pm

Things seem to be working fine on my Banana Pi M64 (running 64-bit (aarch64) Armbian). The problem seems to be a mis-built toolchain for 32-bit arm (bad -march options?).

RobertHeller
Posts: 7
Joined: Sat Jun 25, 2022 3:44 pm

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby RobertHeller » Fri Jul 08, 2022 8:27 pm

ESP_Sprite wrote:
Sun Jun 26, 2022 2:31 am
What esp-idf version is this? Can you try updating to the master branch to see if this is still an issue?
OK, I finally go around to updating to the master branch. Different error:

Code: Select all

-- Building ESP-IDF components for target esp32
CMake Error at /home/heller/esp-idf/tools/cmake/build.cmake:249 (message):
  Failed to resolve component 'mdns'.
Call Stack (most recent call first):
  /home/heller/esp-idf/tools/cmake/build.cmake:285 (__build_resolve_and_add_req)
  /home/heller/esp-idf/tools/cmake/build.cmake:286 (__build_expand_requirements)
  /home/heller/esp-idf/tools/cmake/build.cmake:580 (__build_expand_requirements)
  /home/heller/esp-idf/tools/cmake/project.cmake:434 (idf_build_process)
  CMakeLists.txt:16 (project)


-- Configuring incomplete, errors occurred!
See also "/home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1
Executing action: all (aliases: build)
Running cmake in directory /home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF/build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -DCCACHE_ENABLE=0 /home/heller/RRCircuits/ESP32-D0WD-V3-MultiFunctionOpenMRNIDF"...

davidzuhn
Posts: 17
Joined: Fri Sep 20, 2019 1:50 am

Re: CMake error: The C compiler is not able to compile a simple test program.

Postby davidzuhn » Fri Jul 08, 2022 9:45 pm

mdns has moved to be a separate component now.

Run 'idf.py add-dependency espressif/mdns==1.0.3' in your project and then build. You'll end up with a 'dependencies.lock' file that you should add to your version control.

Who is online

Users browsing this forum: Bing [Bot], VinayDand and 424 guests