[SOLVED] Problem compiling hello world on Linux Mint 17.1

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
bstuckmeyer

[SOLVED] Problem compiling hello world on Linux Mint 17.1

Post by bstuckmeyer »

I just purchased Linux Mint 17.1 Cinnamon (64 bit) on a bootable USB flash drive from OSDisc.com. The system boots and the desktop loads just fine. When I try to compile the following hello world program (via gcc hello.c -o hello):

#include <stdio.h>

main()
{
printf("Hello world.\n");
return(0);
}

I receive the error:

fatal error: stdio.h: No such file or directory

When I run "locate stdio.h" it reports:

/usr/lib/syslinux/com32/include/stdio.h

If I attempt to compile by adding -I/usr/lib/syslinux/com32/include to the gcc command line, stdio.h is found but I receive the following messages:

In file included from hello.c:1:0:
/usr/lib/syslinux/com32/include/stdio.h: In function ‘fileno’:
/usr/lib/syslinux/com32/include/stdio.h:39:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
return (int)(size_t) __f - 1;
^
/usr/lib/syslinux/com32/include/stdio.h: In function ‘fdopen’:
/usr/lib/syslinux/com32/include/stdio.h:43:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1))
^
/usr/lib/syslinux/com32/include/stdio.h:56:12: note: in expansion of macro ‘__create_file’
return __create_file(__fd);
^
/usr/lib/syslinux/com32/include/stdio.h: At top level:
/usr/lib/syslinux/com32/include/stdio.h:74:17: warning: conflicting types for built-in function ‘fwrite’ [enabled by default]
__extern size_t fwrite(const void *, size_t, size_t, FILE *);
^
/usr/lib/syslinux/com32/include/stdio.h:97:14: warning: conflicting types for built-in function ‘snprintf’ [enabled by default]
__extern int snprintf(char *, size_t n, const char *, ...);
^
/usr/lib/syslinux/com32/include/stdio.h:98:14: warning: conflicting types for built-in function ‘vsnprintf’ [enabled by default]
__extern int vsnprintf(char *, size_t n, const char *, va_list);
^
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Seems like, at a minimum, stdio.h is not in the correct location and should probably be in /usr/include/linux along with the other standard C header files. Is there a development package that I need to install?

Any help will be appreciated.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 30243
Joined: Wed Jul 06, 2011 3:58 am

Re: Problem compiling hello world on Linux Mint 17.1

Post by xenopeek »

Have you installed the package build-essential? You need to install that for full library and compiler stack for C/C++ compilation.
Image
bstuckmeyer

Re: Problem compiling hello world on Linux Mint 17.1

Post by bstuckmeyer »

I installed build-essential and that fixed my problem. Thank you very much.
Ph0z3

Re: Problem compiling hello world on Linux Mint 17.1

Post by Ph0z3 »

please see my signature.
Locked

Return to “Beginner Questions”