Introduction to Zephyr Part 2: CMake Tutorial: Errors after cmake --build build

I followed chapter 2 of Shawn Hymels Intro to Zephyr.

cmake creates a build directory, but when I invoke the compilation process via

cmake --build build

I get the following error message from ld:

(venv) root@1960819543e4:/workspace/apps/02_mydemo# cmake -S . -B build
– The C compiler identification is GNU 14.2.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: /usr/bin/cc - skipped
– Detecting C compile features
– Detecting C compile features - done
– Configuring done (3.0s)
– Generating done (0.8s)
– Build files have been written to: /workspace/apps/02_mydemo/build

(venv) root@1960819543e4:/workspace/apps/02_mydemo# cmake --build build
[ 25%] Building C object CMakeFiles/my_lib.dir/src/my_lib.c.o
[ 50%] Linking C static library libmy_lib.a
[ 50%] Built target my_lib
[ 75%] Building C object CMakeFiles/hello_world.dir/src/main.c.o
[100%] Linking C executable hello_world
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function _start': (.text+0x17): undefined reference to main’
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/hello_world.dir/build.make:102: hello_world] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:122: CMakeFiles/hello_world.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
(venv) root@1960819543e4:/workspace/apps/02_mydemo#

What is the reason for this error and what can I do?

1 Like

Hello,

Welcome to the TechForum.

We are looking into this question and should get back to you as soon as we can to offer some advice.

Thank you
Ryan