umanovskis / baremetal-arm

An ebook about bare-metal programming for ARM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CMake Build Issue

jpc0016 opened this issue · comments

Thanks again for all you've done. I run into an issue in chapter 5 while building the project with cmake/make. It appears cmake will create files with a .obj extension instead of .o and can't figure out how this happens. Stack Overflow has not been helpful:

john@embedded:~/Desktop/arm-example$ cmake -S . -Bbuild
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- The C compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/john/Desktop/arm-example/build
john@embedded:~/Desktop/arm-example$ cd build
john@embedded:~/Desktop/arm-example/build$ make
Scanning dependencies of target u-boot
[  0%] Built target u-boot
Scanning dependencies of target bare-metal
[ 33%] Building C object CMakeFiles/bare-metal.dir/src/cstart.c.obj
[ 66%] Building ASM object CMakeFiles/bare-metal.dir/src/startup.s.obj
[100%] Linking C executable bare-metal.elf
/usr/lib/gcc/arm-none-eabi/6.3.1/../../../arm-none-eabi/bin/ld: cannot find startup.o
collect2: error: ld returned 1 exit status
CMakeFiles/bare-metal.dir/build.make:112: recipe for target 'bare-metal.elf' failed
make[2]: *** [bare-metal.elf] Error 1
CMakeFiles/Makefile2:131: recipe for target 'CMakeFiles/bare-metal.dir/all' failed
make[1]: *** [CMakeFiles/bare-metal.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Just reached the same point myself. After chapter 04, line 14 of the linkscript is modified from:

startup.o (.vector_table)
to
*(.vector_table)

Updating my linkscript solved that error.