top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

GCC: How does make command work ?

0 votes
GCC: How does make command work ?
posted Jul 5, 2014 by Neelam

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Make utility is used to create the binary or libraries. It is very helpful and avoid to write gcc command manually.
Usually a big may have thousands of files and it is very tedious to write gcc command manually to build up the binary.

In Simple term, it is described as:
Target: Dependency1 Dependency2
action required to achieve target.

For example:
I have following files in same directory.
my_file.h - Header file which includes function prototype
my_file.c - Function defined in my_file.c file
main.c - Function called from here.
myBin- binary or executable

Target: Dependency1 Dependency2
myBin: main.o my_file.o
gcc -I . -c main.o my_file.o

Target: Dependency1
main.o: main.c my_file.h
gcc -I . -c main.c

my_file.o: my_file.c my_file.h
gcc -I . -c my_file.c

answer Jul 5, 2014 by Rupam
Similar Questions
+1 vote

in the following code func.c :

 int Myfunc1(int i, int z)
 return i;

 int main()
 int ans;

 /* casting the function into an 'int (int)' function */
 ans = ((int(*)(int))(Myfunc1))(5);

 printf("ans: %dnn", ans);

 return 0;

I tried to cast an int(int,int) function into an int(int) function an got the gcc warning and note:

 func.c:13:32: warning: function called through a non-compatible type [enabled by default]
 func.c:13:32: note: if this code is reached, the program will abort

and when trying to run I get:

 Illegal instruction (core dumped)

But if i compile this file with a .cpp ending with the gcc compiler it works OK.

+2 votes

I'm working on a program where a few switch statements end up being hotspots. Some manual experimentation shows that rearranging switch cases so that more commonly executed ones appear together helps, as does checking for the most common case separately. The downside is that it makes the code uglier. Can GCC perform these kinds of optimizations as part of PGO, and how good is it at it?

0 votes

For the below simple case, I think poly1[i] should be hoisted to outermost loop to avoid loading from innermost loop at each iteration.
But for arm-none-eabi target like cortex-m4, gcc fails to do so. I this a normal case or a missing optimization? Please advise.

PolyMul (float *poly1, unsigned int n1,
 float *poly2, unsigned int n2,
 float *polymul, unsigned int *nmul)
 unsigned int i, j;

 for (i = 0; i for (j = 0; j polymul[i+j] += poly1[i] * poly2[j];
+1 vote

I'm on /dev/sda7. I want to install gcc with C++ support in /dev/sda2.

  1. Is it possible to install gcc in /dev/sda2?
  2. What are the dependencies to install gcc? Or which packages should I install there in /dev/sda2 before installing gcc?
  3. What is cross compiler? How can I install gcc as cross compiler? When do we need to install gcc as cross compiler?
  4. Can someone explain the method of installing cross compiled gcc?
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.