Installing GRUB2 onto Mac OS X. Getting weird flex error.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Installing GRUB2 onto Mac OS X. Getting weird flex error.

Post by HittmanA »

I am trying to install GRUB2 on Mac OS X 10.12 so I can continue following the bare bones tutorial. To install it I am following the tutorial for Mac OS X on the os dev site. When I get to configure portion I copied down the command exactly and when I run it I get this:

Code: Select all

checking build system type... x86_64-apple-darwin16.0.0
checking host system type... x86_64-apple-darwin16.0.0
checking target system type... i386-pc-elf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ../../grub-2.00/build-aux/install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for cmp... cmp
checking for bison... bison
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... -ll
checking whether yytext is a pointer... yes
checking for bison... (cached) bison
checking whether make sets $(MAKE)... (cached) yes
checking whether ln -s works... yes
configure: error: flex is too old. GRUB requires 2.5.35 or above
How should I update flex or am I doing something else wrong? Thanks in advance!
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by iansjack »

User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by dozniak »

iansjack wrote:https://www.macports.org/ports.php?by=name&substr=flex

You meant

Code: Select all

brew install flex
Learn to read.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by iansjack »

I've no desire to participate in a religious war about the best package manager for OS X. But I know what I meant.

Learn to read.
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by HittmanA »

So I installed it via homebrew (It's just a personal preference). It said:

Code: Select all

Warning: flex-2.6.3 already installed, it's just not linked.
Now how do I link it so it can be used?
User avatar
MajickTek
Member
Member
Posts: 101
Joined: Sat Dec 17, 2016 6:58 am
Libera.chat IRC: MajickTek
Location: The Internet
Contact:

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by MajickTek »

Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
Everyone should know how to program a computer, because it teaches you how to think! -Steve Jobs

Code: Select all

while ( ! ( succeed = try() ) ); 
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by HittmanA »

MajickTek wrote:Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
I couldn't use anything different ;P
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by HittmanA »

MajickTek wrote:Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
Also, I am having trouble setting up my toolchain and cross-compiler. Is there a way you could send me your toolchain (e.g. gcc, binutils, grub, etc.)? I would really appreciate it.
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by matt11235 »

HittmanA wrote:
MajickTek wrote:Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
Also, I am having trouble setting up my toolchain and cross-compiler. Is there a way you could send me your toolchain (e.g. gcc, binutils, grub, etc.)? I would really appreciate it.
You should really try to get it building on your own computer, eventually you will be wanting to build a compiler that targets your new operating system.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by dozniak »

HittmanA wrote:So I installed it via homebrew (It's just a personal preference). It said:

Code: Select all

Warning: flex-2.6.3 already installed, it's just not linked.
Now how do I link it so it can be used?
It's keg only, `brew info flex` should show you the linker and include flags to use so it can be found by configure.

Alternatively, you may want to try `brew link flex`, maybe with a force flag
Learn to read.
dlundqvist
Posts: 1
Joined: Tue Jun 16, 2015 4:12 am
Location: Arvika, Sweden
Contact:

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by dlundqvist »

HittmanA wrote:
MajickTek wrote:Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
Also, I am having trouble setting up my toolchain and cross-compiler. Is there a way you could send me your toolchain (e.g. gcc, binutils, grub, etc.)? I would really appreciate it.
I've built a cross compiler targeting i686-elf for macOS. You can download it from http://files.malarhojden.nu/osdev-cross-0.tar.gz

It currently contains:
  • binutils 2.27
  • gcc 6.3.0 (only C at the moment).
  • xorriso 1.4.6
  • grub 2.02rc1
Extract in /usr/local and it will be installed to /usr/local/osdev-cross/. Add /usr/local/osdev-cross/bin to PATH and you can use i686-pc-gcc etc. to build your stuff.

If I have time and there is interest I could extend this to include more useful programs, like qemu, and languages, like C++.

Let me know if you have any issues.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by Schol-R-LEA »

Hold on for a moment: are you trying to build GRUB2 using your cross-compiler so you can install it into a disk image which you can run in an emulator or virtualizer, or are you trying to install it on the Mac itself? The way you said it sounds like the latter, and that is not recommended for OS development, especially if you are at the stage of working with the Bare Bones tutorial.

You generally don't want your OS running on bare hardware until you are much farther along, and even then, unless you are really confident in your OS, you generally don't want to multiboot it on the same system you are developing on. You can, if you want to - in the bad old days the usual process was to install it on a floppy and boot live - but given the availability emulators such as Bochs and virtualizers such as Virtualbox and QEMU, doing that as part of the general development process is going to be more trouble than it is worth. I recommend that you make sure it runs well in one or more emulators first, then test it booting into hardware using a separate boot disk.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by HittmanA »

Schol-R-LEA wrote:Hold on for a moment: are you trying to build GRUB2 using your cross-compiler so you can install it into a disk image which you can run in an emulator or virtualizer, or are you trying to install it on the Mac itself? The way you said it sounds like the latter, and that is not recommended for OS development, especially if you are at the stage of working with the Bare Bones tutorial.

You generally don't want your OS running on bare hardware until you are much farther along, and even then, unless you are really confident in your OS, you generally don't want to multiboot it on the same system you are developing on. You can, if you want to - in the bad old days the usual process was to install it on a floppy and boot live - but given the availability emulators such as Bochs and virtualizers such as Virtualbox and QEMU, doing that as part of the general development process is going to be more trouble than it is worth. I recommend that you make sure it runs well in one or more emulators first, then test it booting into hardware using a separate boot disk.
I am trying to use GRUB's command line tools so I can make my os.bin into an .iso that emu can run.
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by HittmanA »

dlundqvist wrote:
HittmanA wrote:
MajickTek wrote:Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
Also, I am having trouble setting up my toolchain and cross-compiler. Is there a way you could send me your toolchain (e.g. gcc, binutils, grub, etc.)? I would really appreciate it.
I've built a cross compiler targeting i686-elf for macOS. You can download it from http://files.malarhojden.nu/osdev-cross-0.tar.gz

It currently contains:
  • binutils 2.27
  • gcc 6.3.0 (only C at the moment).
  • xorriso 1.4.6
  • grub 2.02rc1
Extract in /usr/local and it will be installed to /usr/local/osdev-cross/. Add /usr/local/osdev-cross/bin to PATH and you can use i686-pc-gcc etc. to build your stuff.

If I have time and there is interest I could extend this to include more useful programs, like qemu, and languages, like C++.

Let me know if you have any issues.
Thank you! I will try installing this now.
HittmanA
Posts: 10
Joined: Fri Feb 24, 2017 6:51 pm

Re: Installing GRUB2 onto Mac OS X. Getting weird flex error

Post by HittmanA »

dlundqvist wrote:
HittmanA wrote:
MajickTek wrote:Finally I found someone who is developing on my OS of preference... My main computer is an iMac and I love developing on that thing <3
Also, I am having trouble setting up my toolchain and cross-compiler. Is there a way you could send me your toolchain (e.g. gcc, binutils, grub, etc.)? I would really appreciate it.
I've built a cross compiler targeting i686-elf for macOS. You can download it from http://files.malarhojden.nu/osdev-cross-0.tar.gz
~snip~
Thanks again! I just tested it out and I can now successfully compile my kernel.
Post Reply