I am learning C and because VC++ 2008 doesn't support C99 features I have just installed NetBeans and configure it to work with MinGW. I can compile single file project ( main.c) and use debugger but when I add new file to project I get error "undefined reference to ... function(code) in that file..". Obviously MinGW does't link my files or I don't know how properly add them to my project (c standard library files work fine).
/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/don/Documents/NetBeansProjects/CppApplication_7'
/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_7.exe
make[2]: Entering directory `/c/Users/don/Documents/NetBeansProjects/CppApplication_7'
mkdir -p dist/Debug/MinGW-Windows
gcc.exe -o dist/Debug/MinGW-Windows/cppapplication_7 build/Debug/MinGW-Windows/main.o
build/Debug/MinGW-Windows/main.o: In function `main':
C:/Users/don/Documents/NetBeansProjects/CppApplication_7/main.c:5: undefined reference to `X'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/cppapplication_7.exe] Error 1
make[2]: Leaving directory `/c/Users/don/Documents/NetBeansProjects/CppApplication_7'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/don/Documents/NetBeansProjects/CppApplication_7'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
main.c
#include "header.h"
int main(int argc, char** argv)
{
X();
return (EXIT_SUCCESS);
}
header.h
#ifndef _HEADER_H
#define _HEADER_H
#include <stdio.h>
#include <stdlib.h>
void X(void);
#endif
source.c
#include "header.h"
void X(void)
{
printf("dsfdas");
}