Missing stdint.h

Programming, for all ages and all languages.
Post Reply
rhughes
Posts: 16
Joined: Thu Apr 22, 2010 7:01 am

Missing stdint.h

Post by rhughes »

Hello All

I am running Ubuntu 12.04 x64

I have (apparently) completed Step 1 of setting up a Cross Compiler as defined here: http://wiki.osdev.org/GCC_Cross-Compiler

When I try to compile the Kernel.c code described here: http://wiki.osdev.org/Bare_Bones

I get the attached error.

I have actioned: make all-target-libgcc
make install-target-libgcc

So I am guessing it is a directory error of some sort.

I am more of a Windows person than Linux so forgive me if this is a simple issue to solve.

Thank you all very much for your help,

Richard Hughes
Attachments
Respective error
Respective error
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Missing stdint.h

Post by Love4Boobies »

The problem is actually with the GCC Cross-Compiler article. The Bare Bones tutorial was recently updated to use the freestanding library for portability reasons, yet the GCC cross-compiler is built using the --without-headers flag. I'm not sure whether there's a configuration flag to instruct only the installation of the freestanding library or whether it needs to be installed separately but I will take a look and update the wiki accordingly. In the meantime, you can temporarily write your own implementation of <stdint.h> (for the purposes of that tutorial, it only needs to have "typedef unsigned int uint32_t;" --- note that this is specific to the GCC cross-compiler you have built, don't expect it to work everywhere) or use one of these libraries.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Missing stdint.h

Post by Love4Boobies »

For 64-bit compatibility, he'd want uint32_t to be a 64-bit unsigned integer type? For 64-bit incompatibility, maybe. :) My version works with both the AMD64 and Inte386 SysV ABIs.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Missing stdint.h

Post by bluemoon »

I build cross compiler according to the wiki article, the standard header is shipped with libgcc even with --without-headers

Code: Select all

$ ls /usr/local/cross/lib/gcc/x86_64-elf/4.6.3/include
abmintrin.h  bmmintrin.h     float.h       iso646.h     mm_malloc.h     smmintrin.h  stdfix.h      tgmath.h     wmmintrin.h
ammintrin.h  cpuid.h         fma4intrin.h  lwpintrin.h  nmmintrin.h     stdarg.h     stdint-gcc.h  tmmintrin.h  x86intrin.h
avxintrin.h  cross-stdarg.h  ia32intrin.h  mm3dnow.h    pmmintrin.h     stdbool.h    stdint.h      unwind.h     xmmintrin.h
bmiintrin.h  emmintrin.h     immintrin.h   mmintrin.h   popcntintrin.h  stddef.h     tbmintrin.h   varargs.h    xopintrin.h
PS: Don't sudo gcc for the obvious reason.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Missing stdint.h

Post by Solar »

<stdint.h> is built regardless, that is correct. If the options we give in the tutorials don't make those includes "visible", we should change them...

I don't have a cross-compiler active ATM so I cannot test, and I don't really have the time to set things up for testing... someone else to step into the breach?
Every good solution is obvious once you've found it.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Missing stdint.h

Post by bluemoon »

I just add -I/usr/local/cross/..... to the compile option until I pull in newlib, which also provide those headers.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Missing stdint.h

Post by Love4Boobies »

I didn't notice you wrote size_t rather than uint32_t either. Your second snippet isn't C, it's GCC-ism, so I would have to disagree with it.
Last edited by Love4Boobies on Wed Jun 06, 2012 4:27 am, edited 1 time in total.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Missing stdint.h

Post by Love4Boobies »

If you're using it with clang, it's because it supports GCC-specific extensions. Regardless of what compiler you're using, it's not really C.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Missing stdint.h

Post by Love4Boobies »

Fair enough. Given that the OP mentioned the Bare Bones tutorial, I just happened to make the mistake of thinking that your answer wasn't about the wrong data type, wrong compiler, and wrong language. :)
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply