歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

GeekOS編譯於64位Linux系統

開始GeekOS之旅的時候,一開始就碰到了小麻煩,在自己64位的Fedora上編譯GeekOS的時候報如下錯誤:

  1. geekos/lowlevel.o: could not read symbols: File in wrong format  

斷定是平台問題.再去官網看了下:
  1. GeekOS is a tiny operating system kernel for x86 PCs.  

看了後就決定換i386系統了,裝上後就發現很多需要配置,太麻煩,稍微思考片刻,記得以前在編譯其它i386代碼時,是可以跨平台的,編譯時搜索lib32庫不就行了嘛.研究了下GeekOS的Makefile.

GeekOS提供的Makefile中是有編譯於X64的配置的.拿 project0的Makefile來說,在第97行(GeekOS-0.3.0) 把TARGECT_CC_PREFIX打開就可以了. 但是你的OS需要安裝Cross-development的開發包.

不過沒關系,還有個方法就是加編譯選項 -m32 和 鏈接選項 -m elf_i386 這樣會在編譯時自動去找lib32.在GeekOS的 Makefile中第100,106,109行改成如下:

  1. 100 TARGET_CC := $(TARGET_CC_PREFIX)gcc -m32                                                    
  2. 101   
  3. 102 # Host C compiler.  This is used to compile programs to execute on                          
  4. 103 # the host platform, not the target (x86) platform.  On x86/ELF  
  5. 104 # systems, such as Linux and FreeBSD, it can generally be the same                          
  6. 105 # as the target C compiler.                                                                 
  7. 106 HOST_CC := gcc -m32                                                                         
  8. 107   
  9. 108 # Target linker.  GNU ld is probably to only one that will work.                            
  10. 109 TARGET_LD := $(TARGET_CC_PREFIX)ld  -m elf_i386              

然後改動後,你可能需要安裝glibc的386版本,fedora安裝如下:

  1. yum -y install glibc-devel.i686  

然後再進行編譯就OK了:

cat geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin > fd.img 

鏡像文件成功生成.

Copyright © Linux教程網 All Rights Reserved