hello
does anyone knows the meaning of the error

undefined reference to main.

i'm getting the error when trying to compile a file without a main function with -Wall option

The error implies that there is some reference to main inside the functions in the file you are trying to compile. As you have not defined main, it will not compile. Try to put the file here so that the error can be located.

hello
does anyone knows the meaning of the error

undefined reference to main.

i'm getting the error when trying to compile a file without a main function with -Wall option

it is queit long but, i will try to explain. i created a file witch contains many functions ( none of them has reference to main) and a second file witch contains a main and uses the functions i created in the first file ( of course i included the first file).
here is an example for the first file :

void polDiv ( float A[] , float B[] , float C[] , int n , int m ) {

int i , j , pow ;

float tmp[(int)n] ;

i = n - 1 ;

j = m - 1 ;

zero ( C , n ) ;

while ( i >= j  ) {

  pow = i - j ;

  C[pow] = A[i] / B[j] ;

  zero ( tmp , n ) ;

  mul ( C[pow] , pow , B , tmp , m ) ;

  sub ( A , tmp , n ) ;

  i-- ;

  } // end while

 } // polDiv end

here is the example for main :

#include "array.h"

void main () {

printf ( "\n\npolDiv :\n\n" ) ;

float N[] = {3,-4,24,-2,-1,3} ;

float M[] = {-3,2,1} ;

float T[(int)6] = {0} ;

printPol (N,6) ;

printf ("divede\n\n") ;

printPol (M,3) ;

polDiv (N,M,T,6,3) ;

printf ("is\n\n") ;

printPol (T,6) ;


return 0 ;

} // end main

First off, main returns an int - no exceptions.

To compile a multi-file project from the command line, it would be gcc -Wall array.c main.c Later on, when you want to get into incremental compilation, the steps would be

gcc -c -Wall array.c
gcc -c -Wall main.c
gcc array.o main.o

It's at this point you'll want to investigate the project options of your IDE, or look into makefiles to automate this kind of stuff.

ok thanks alot
it made all clear

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.