Makefile 未定义的引用;“主要”;在构建操作系统时

Makefile 未定义的引用;“主要”;在构建操作系统时,makefile,linker,osdev,Makefile,Linker,Osdev,我只是在做一个简单的小操作系统,但是我遇到了一个错误。当我尝试构建时,会出现以下错误: 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 refe

我只是在做一个简单的小操作系统,但是我遇到了一个错误。当我尝试构建时,会出现以下错误:

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
joseph@joseph-linuxmint~/Desktop/os$make测试
g++lib/screen.cpp-o lib/screen
/usr/lib/gcc/x86_64-linux-gnu/5/./../../../../x86_64-linux-gnu/crt1.o:在函数“u start”中:
(.text+0x20):对“main”的未定义引用
collect2:错误:ld返回了1个退出状态
:目标“库/屏幕”的配方失败
make:**[lib/screen]错误1

源代码托管在github上:

您的链接已断开。不是吗?如果是,则问题在于您正试图从
lib/screen.cpp
创建可执行文件,而此源代码没有
main
入口点。问题在于
makefile
。替换在对象文件名中添加了不需要的空格<代码>$(subst.cpp、.cpp.o、$(通配符$(LIB)/*.cpp))应该是
$(subst.cpp、cpp.o、$(通配符$(LIB)/*.cpp))
。与其他subst语句相同。您应该注意到,在
.cpp之后,
我删除了逗号后的空格。感谢您的帮助,您的解决方案成功了。有一个名为
-ffreestanding
的更简单参数专门用于操作系统开发,
-m32-ffreestanding
可以满足您的gppparams使用交叉编译器()