使用makefile时,终端上没有printf输出 [英] No output of printf on terminal when using makefile

查看:577
本文介绍了使用makefile时,终端上没有printf输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Makefile:

My Makefile:

HEADERS = headers.h macros.h main.h socket.h
 

main.o : main.c main.h
	cc -c main.c

socket.o : socket.c headers.h macros.h
	cc -c socket.c





main.c



main.c

#include "main.h"
main()
{
printf("%s\n","Connect_Socket Start");
Connect_Socket(IP_ADDRESS, PORT);
printf("%s\n","Connect_Socket End");
   while(1)
   {
       Send_Message();
       Recv_Message();
   }
    Close_Socket();
}





socket.c



socket.c

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h> 
#include <errno.h> 
#include "headers.h"
#include "macros.h"

void Connect_Socket() {
    //definiton...
} 

int Send_Message() {
    //definiton...
}

int Recv_Message() {
   //definiton...
}

void Close_Socket() {
    //definiton...
}





socket.h



socket.h

//function declarations of socket.c





macros.h



macros.h

//Some macros used in socket.c and main.c





headers.h



headers.h

//Includes standard .h files





main.h



main.h

#include "headers.h"
#include "socket.h"
#include "macros.h"

#include "MQTTPacket/MQTTPacket.h"







执行 $ make 在终端上,我没有收到任何错误。但是,我也没有得到任何printf()消息。



我尝试过:



我尝试将我的makefile更改为:




When executing $make on terminal, I am not getting any errors. However, I am also not getting any of the printf() messages.

What I have tried:

I tried changing my makefile to:

cc	=	gcc
OBJFILES	=	socket.o main.o
TARGET	=	mqtt_c8y

all: $(TARGET)

$TARGET: $(OBJFILES)
	$(CC) -o $(TARGET) $(OBJFILES)





但是,在main.c中注释函数调用并使用 $ gcc简单地编译main.c main.c 然后 $。/ a.out ,我得到printf()消息。



However, when commenting the function calls in main.c and compiling simply main.c with $gcc main.c and then $./a.out, I do get the printf() messages.

推荐答案

make 在终端上,我没有收到任何错误。但是,我也没有得到任何printf()消息。



我尝试过:



我尝试将我的makefile更改为:

make on terminal, I am not getting any errors. However, I am also not getting any of the printf() messages.

What I have tried:

I tried changing my makefile to:
cc	=	gcc
OBJFILES	=	socket.o main.o
TARGET	=	mqtt_c8y

all:


(TARGET)


TARGET:


这篇关于使用makefile时,终端上没有printf输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆