0

I'm just working on a tiny simple OS, but I'm getting an error thrown at me. When I try to build I get this error:

joseph@joseph-linuxmint ~/Desktop/os $ make test
g++     lib/screen.cpp   -o lib/screen
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In   function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'lib/screen' failed
make: *** [lib/screen] Error 1

Source code is hosted on github here: https://github.com/HackingNewbie/JoeOSmakefile

  • Your link is broken. Isn't it [https://github.com/HackingNewbie/JoeOS](https://github.com/HackingNewbie/JoeOS), instead? If it is, your problem comes from the fact that you are trying to create an executable from `lib/screen.cpp` while this source code has no `main` entry point. – Renaud Pacalet Jun 10 '18 at 10:07
  • The problem is in your `makefile`. Your substitutions are adding an unwanted space in your object file names. `$(subst .cpp, .cpp.o, $(wildcard $(LIB)/*.cpp))` should be `$(subst .cpp,cpp.o, $(wildcard $(LIB)/*.cpp))` . The same with the other subst statements. You should notice that that after `.cpp,` I removed the space after the comma. – Michael Petch Jun 10 '18 at 10:09
  • Thanks for your help, your solution worked Michael. –  Jun 10 '18 at 12:06
  • There is a simpler parameter called `-ffreestanding` which is dedicated to OS development, `-m32 -ffreestanding` can be enough for your GPPPARAMS – TravorLZH Aug 04 '18 at 08:59
  • Please use a cross-compiler (https://wiki.osdev.org/GCC_Cross-Compiler) – glauxosdever Nov 01 '18 at 21:31

0 Answers0