cfenollosa / os-tutorial

How to create an OS from scratch
BSD 3-Clause "New" or "Revised" License
26.62k stars 3.24k forks source link

GCC Cross Compilation will not work with OS X Catalina Headers #162

Open gmarino2048 opened 4 years ago

gmarino2048 commented 4 years ago

Simple workaround is to set CPATH to /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/. This took me 3 hours to figure out, so I'm hoping this will help someone in the future. If you don't have the 10.14 SDK, you can get it here:

https://github.com/phracker/MacOSX-SDKs

Vesion commented 3 years ago

Another solution which can not bother running cross compilation ourselves:

brew install i686-elf-binutils
brew install i686-elf-gcc
brew install i386-elf-gdb

then in Makefile:

CC = /usr/local/opt/i686-elf-gcc/bin/i686-elf-gcc
LD = /usr/local/opt/i686-elf-binutils/bin/i686-elf-ld
GDB = /usr/local/opt/i386-elf-gdb/bin/i386-elf-gdb
duanbing commented 3 years ago

Hope this help: https://wiki.osdev.org/User:Max/Building_a_GCC_4.9_cross_compiler_on_OS_X_Mavericks

Notice that set the envs:

export CC=gcc-4.9
export CXX=g++-4.9
export CPP=cpp-4.9
export LD=gcc-4.9