Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header files are not found by GCC

Working with embedded C-projects. There are libraries, include files and so on - for micro controllers. No need for me to use GCC for a host machine and OS (Linux Mint 64 bit). As a rule...

But now I'm trying to compile mspdebug project from a Github - with a GCC of course. And I get an error at the very begin of make:

mspdebug$ make
cc  -DUSE_READLINE  -O1 -Wall -Wno-char-subscripts -ggdb -I. -Isimio -Iformats -Itransport -Idrivers -Iutil -Iui -DLIB_DIR=\"/usr/local/lib/\"  -o util/btree.o -c util/btree.c
util/btree.c:19:20: fatal error: assert.h: No such file or directory
 #include <assert.h>
                    ^
compilation terminated.

I search for the includes in all possible paths (I've got the list of them via gcc -v command) - there are no assert.h file, as well, as stdio.h and so on. Except virtual box directories there is only one place (where GCC does not search includes): /usr/lib/syslinux/com32/include

AFAIK, all standard libs and includes are installed with the GCC. So I try to reinstall GCC (4.8.4) - nothing changes.

What is the normal way to give GCC all standard environment it needs?

like image 384
drvlas Avatar asked Dec 25 '15 22:12

drvlas


People also ask

Where is the header files in GCC?

These are the directories that gcc looks in by default for the specified header files ( given that the header files are included in chevrons <>); 1. /usr/local/include/ --used for 3rd party header files. 2. /usr/include/ -- used for system header files.

How does GCC search for header files?

GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets. For example, if /usr/include/sys/stat. h contains #include "types.

Do you need to include header files in GCC?

GCC needs to install corrected versions of some system header files. This is because most target systems have some header files that won't work with GCC unless they are changed. Some have bugs, some are incompatible with ISO C, and some depend on special features of other compilers.

HOW include header file in C linux?

To import a header, use the #include, a preprocessor directive telling the compiler that it should import and process the code before compiling the rest of the code. On a typical C program, it should contain the stdio. h header file, which is the standard header file for input and output streams.


2 Answers

Thanks to the right direction set by Sam Varshavchik I found the info in the stackoverflow. So I did the following:

1) installed build-essential:

sudo apt-get install build-essential

2) installed libusb (since my try to build the package revealed the absence of usb.h):

sudo apt-get install libusb-dev

And it is OK! The mspdebug (v.023) is compiled and successfully tested!

So, Linux Mint 17.2 (at least) requires installing some libs to a GCC, the most basic is build-essential.

like image 100
drvlas Avatar answered Oct 24 '22 07:10

drvlas


assert.h is not part of gcc, it's a part of glibc.

Most likely, your Linux distribution puts the system headers into a separate package that you need to install.

Fedora, for examples, puts the header files in the glibc-headers package. However, you can't be using Fedora, because Fedora's gcc package has a dependency on glibc-headers, to make sure that it gets pulled in.

Whatever Linux distribution you're using, you need to research which distribution package will install the system header files you need to build stuff with.

like image 3
Sam Varshavchik Avatar answered Oct 24 '22 09:10

Sam Varshavchik