UNIX - makefile 求助!
在下面寻求编译我的程序的帮助。我收到一条“***停止。没有目标”。在编译器缓冲区中输入 limit.makefile 时出错。有想法吗?
int main(int argc, char *argv[]) {
struct rlimit limit;
limit.rlim_cur = 60000;
limit.rlim_max = 60000;
if (setrlimit(RLIMIT_FSIZE, &limit) == -1){
perror("Error preventing core dump, errno=%d\n", errno);
exit(1);
}
else {
printf("The current core limit is %ll.\n", limit.rlim_cur);
printf("The core max limit is %ll.\n", limit.rlim_max);
exit(0);
}
if (getrlimit(RLIMIT_FSIZE, &limit) == -1){
printf("getlimit() failed with errno=%d\n", errno);
exit(1);
}
}
编译命令:make -k -f limit.makefile
这就是我为编译器缓冲区输入的内容......但仍然收到错误。
生成文件:
CC = /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
Looking for help compiling my program below. I'm getting a "***Stop. no Targets." error when typing in limit.makefile in the compiler buffer. Ideas?
int main(int argc, char *argv[]) {
struct rlimit limit;
limit.rlim_cur = 60000;
limit.rlim_max = 60000;
if (setrlimit(RLIMIT_FSIZE, &limit) == -1){
perror("Error preventing core dump, errno=%d\n", errno);
exit(1);
}
else {
printf("The current core limit is %ll.\n", limit.rlim_cur);
printf("The core max limit is %ll.\n", limit.rlim_max);
exit(0);
}
if (getrlimit(RLIMIT_FSIZE, &limit) == -1){
printf("getlimit() failed with errno=%d\n", errno);
exit(1);
}
}
Compile command: make -k -f limit.makefile
This is what I type for the compiler buffer....still get the error though.
Makefile:
CC = /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
刚刚尝试在空文件上 make -k -f myfile 并收到错误。
如果您只是想让它工作
请注意,所有选项卡下的选项卡必须是“真实”选项卡。
我建议您查看 makefile 教程或仅从命令行编译它。
gcc -g -Wall -std=c99 -O2 -arch x86_64 limit.c
顺便说一句,不确定 -arch 标志。在我的 Linux 机器上无效。
Just tried that make -k -f myfile on an empty file and got your error.
If you just want it to work
Note that the tab under all has to be a "real" tab.
I recommend you check out a makefile tutorial or just compile it from the command line.
gcc -g -Wall -std=c99 -O2 -arch x86_64 limit.c
BTW, not sure about that -arch flag. Not valid on my Linux box.
尝试
Try
EboMike 的更为复杂,但这里有一个更简单的,保证适用于您的单文件项目:
您可以仅使用
make
本身来运行它。EboMike's is more sophisticated, but here's a simpler one that is guaranteed to work for your one-file project:
You can run this with just
make
by itself.您还没有在任何地方定义要构建的目标。您可以在命令行上执行此操作,使用命令
和
make
的隐式规则将limit.c
编译为limit
。或者在 makefile 中定义一个目标,默认情况下将构建第一个目标,并且 make 知道如何将
*.c
编译为*.o
并链接目标文件,以便一切否则是自动的。如果您好奇,默认规则相当于(在 GNU make 中),
其中
$@
、$<
和$^
扩展为分别是目标、第一个先决条件和所有先决条件,百分号是目标名称的通配符。You've not defined what the target to build is anywhere. You can do that on the command line, using the command
and the implicit rules of
make
will compilelimit.c
intolimit
. Alternatively define a target in your makefile,The first target will be built by default, and make knows how to compile
*.c
to*.o
and link object files so everything else is automatic.If you're curious, the default rules are equivalent to (in GNU make)
where
$@
,$<
and$^
expand to the target, first prereq and all prereqs respectively, the percent signs are wildcards for the target name.