在netbeansc中使用header
我试图在在netbeansc中使用header,c,netbeans,header,C,Netbeans,Header,我试图在Netbeans中编译一个简单的C程序,其中包含一个头文件、一个main文件和另一个源文件,但没有成功。我总是收到一个巨大的错误信息 我完全不知道我能做些什么使它工作。希望你们能帮我 控制台: "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory `/home/***/***/***/***/***/headertest' nbp
Netbeans
中编译一个简单的C程序,其中包含一个头文件、一个main文件和另一个源文件,但没有成功。我总是收到一个巨大的错误信息
我完全不知道我能做些什么使它工作。希望你们能帮我
控制台:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/***/***/***/***/***/headertest'
nbproject/Makefile-Debug.mk:73: warning: overriding commands for target `build/Debug/GNU-Linux-x86/header.o'
nbproject/Makefile-Debug.mk:68: warning: ignoring old commands for target `build/Debug/GNU-Linux-x86/header.o'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/headertest
make[2]: Entering directory `//home/***/***/***/***/***/headertest'
nbproject/Makefile-Debug.mk:73: warning: overriding commands for target `build/Debug/GNU-Linux-x86/header.o'
nbproject/Makefile-Debug.mk:68: warning: ignoring old commands for target `build/Debug/GNU-Linux-x86/header.o'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/header.o.d"
gcc -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/header.o.d" -o build/Debug/GNU-Linux-x86/header.o header.h
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/main.o.d"
gcc -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/main.o.d" -o build/Debug/GNU-Linux-x86/main.o main.c
mkdir -p dist/Debug/GNU-Linux-x86
gcc -o dist/Debug/GNU-Linux-x86/headertest build/Debug/GNU-Linux-x86/header.o build/Debug/GNU-Linux-x86/header.o build/Debug/GNU-Linux-x86/main.o
/usr/bin/ld:build/Debug/GNU-Linux-x86/header.o: file format not recognized; treating as linker script
/usr/bin/ld:build/Debug/GNU-Linux-x86/header.o:1: syntax error
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/headertest] Error 1
make[2]: Leaving directory `/home/***/***/***/***/***/headertest'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/***/***/***/***/***/headertest'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 283ms)
以下是我的代码的其余部分:
main.c
标题.h
#ifndef HEADER_H
#define HEADER_H
#ifdef __cplusplus
extern "C" {
#endif
void lol();
#ifdef __cplusplus
}
#endif
#endif /* HEADER_H */
您尚未包括
stdio.h
。您的lol()
函数不知道printf()
将
#include
放入header.c
或header.h
为什么要编译头文件?根据日志,您正在编译header.h,而您应该编译header.cok谢谢。我如何更改在netbeans中编译的文件?
#include "header.h"
void lol(){
printf("lol");
}
#ifndef HEADER_H
#define HEADER_H
#ifdef __cplusplus
extern "C" {
#endif
void lol();
#ifdef __cplusplus
}
#endif
#endif /* HEADER_H */