Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在netbeansc中使用header_C_Netbeans_Header - Fatal编程技术网

在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 */