I have written a Makefile which compiles my mini-os with another application. I have to use -nostdioc
and -nostdlib
to compile them, but the problem is, that application is using stdio/stdlib functions and when I run my Makefile I get the error message that the functions used by my application cannot be found.
我已经编写了一个Makefile,它用另一个应用程序编译我的迷你操作系统。我必须使用- dioc和- dlib来编译它们,但问题是,应用程序使用stdio/stdlib函数,当我运行Makefile时,我得到错误消息,我的应用程序所使用的函数无法被找到。
I tried to remove the -nostdlib
-nostdioc
but that did not work.
我试着移走了绞股蓝,但那没用。
Here is the Makefile if anyone would like to take a look.
这是Makefile,如果有人想看一看。
1 个解决方案
#1
3
-nostdlib
tells gcc to not include tells the compiler to not include the standard libraries, one of them being glibc (the GNU libc). -nostdinc
tells the compiler not to use the standard paths for header files. The functions with prototypes in stdlib.h and stdio.h are part of libc which you have told the gcc not to use. Therefore you will need to implement them yourself or include a libc explicitly (some common ones to use for custom operating systems are newlib and uClibc). Which approach is easier depends on the functions being used. I should add that at this point if you are trying to compile an operating system and an application, even a static application, you might want to look into using a cross-compiler (http://wiki.osdev.org/GCC_Cross-Compiler) and if you can get that working the next step is your own toolchain which includes a libc (http://wiki.osdev.org/OS_Specific_Toolchain).
- dlib告诉gcc不包括告诉编译器不包含标准库,其中一个是glibc (GNU libc)。- dinc告诉编译器不要使用标头文件的标准路径。在stdlib中使用原型的函数。h和它的。h是libc的一部分,您已经告诉gcc不要使用它。因此,您需要自己实现它们,或者显式地包含一个libc(一些常用的用于自定义操作系统的是newlib和uClibc)。哪种方法更容易依赖于所使用的函数。我应该补充说,在这一点上,如果你试图编译一个操作系统和应用程序,甚至是一个静态的应用程序中,您可能希望考虑使用交叉编译器(http://wiki.osdev.org/GCC_Cross-Compiler),如果你可以,下一步工作是自己的工具链包括libc(http://wiki.osdev.org/OS_Specific_Toolchain)。
If implementing the necessary functions is not an option than your best bet is to use a full toolchain including your own libc. You cannot simply use the GNU libc as part of what libc is is a wrapper around the system calls and you would have to have a kernel that has a system call interface that is the same as the host operating system. Note that part of the process of porting a libc to your operating system is implementing the system calls. For newlib this includes but is not limited to write, read, open, close, fork and exec. If your application does not use these system calls you can simply implementing dummy versions.
如果实现必要的功能不是一个选项,那么最好的方法是使用完整的工具链,包括您自己的libc。您不能简单地使用GNU libc作为libc的一部分,它是一个围绕系统调用的包装器,您必须拥有一个具有与主机操作系统相同的系统调用接口的内核。注意,将libc移植到操作系统的部分过程是实现系统调用。对于newlib,这包括但不限于写入、读取、打开、关闭、fork和exec。如果您的应用程序不使用这些系统调用,您可以简单地实现虚拟版本。
#1
3
-nostdlib
tells gcc to not include tells the compiler to not include the standard libraries, one of them being glibc (the GNU libc). -nostdinc
tells the compiler not to use the standard paths for header files. The functions with prototypes in stdlib.h and stdio.h are part of libc which you have told the gcc not to use. Therefore you will need to implement them yourself or include a libc explicitly (some common ones to use for custom operating systems are newlib and uClibc). Which approach is easier depends on the functions being used. I should add that at this point if you are trying to compile an operating system and an application, even a static application, you might want to look into using a cross-compiler (http://wiki.osdev.org/GCC_Cross-Compiler) and if you can get that working the next step is your own toolchain which includes a libc (http://wiki.osdev.org/OS_Specific_Toolchain).
- dlib告诉gcc不包括告诉编译器不包含标准库,其中一个是glibc (GNU libc)。- dinc告诉编译器不要使用标头文件的标准路径。在stdlib中使用原型的函数。h和它的。h是libc的一部分,您已经告诉gcc不要使用它。因此,您需要自己实现它们,或者显式地包含一个libc(一些常用的用于自定义操作系统的是newlib和uClibc)。哪种方法更容易依赖于所使用的函数。我应该补充说,在这一点上,如果你试图编译一个操作系统和应用程序,甚至是一个静态的应用程序中,您可能希望考虑使用交叉编译器(http://wiki.osdev.org/GCC_Cross-Compiler),如果你可以,下一步工作是自己的工具链包括libc(http://wiki.osdev.org/OS_Specific_Toolchain)。
If implementing the necessary functions is not an option than your best bet is to use a full toolchain including your own libc. You cannot simply use the GNU libc as part of what libc is is a wrapper around the system calls and you would have to have a kernel that has a system call interface that is the same as the host operating system. Note that part of the process of porting a libc to your operating system is implementing the system calls. For newlib this includes but is not limited to write, read, open, close, fork and exec. If your application does not use these system calls you can simply implementing dummy versions.
如果实现必要的功能不是一个选项,那么最好的方法是使用完整的工具链,包括您自己的libc。您不能简单地使用GNU libc作为libc的一部分,它是一个围绕系统调用的包装器,您必须拥有一个具有与主机操作系统相同的系统调用接口的内核。注意,将libc移植到操作系统的部分过程是实现系统调用。对于newlib,这包括但不限于写入、读取、打开、关闭、fork和exec。如果您的应用程序不使用这些系统调用,您可以简单地实现虚拟版本。