Click here to Skip to main content
15,946,158 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Makefile:
C++
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
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
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
C++
//function declarations of socket.c


macros.h
C++
//Some macros used in socket.c and main.c


headers.h
C++
//Includes standard .h files


main.h
C++
#include "headers.h"
#include "socket.h"
#include "macros.h"

#include "MQTTPacket/MQTTPacket.h"



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:
C++
cc	=	gcc
OBJFILES	=	socket.o main.o
TARGET	=	mqtt_c8y

all: $(TARGET)

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


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.
Posted
Updated 17-Aug-18 2:40am

Ata guess - and without your computer to hand that's all it can be - you don't get the output because the app is too busy connecting the socket to update the display.

Try adding a user input after the printf and see what happens.
 
Share this answer
 
Executing make will build the target according to the specifed rules.

But it will not execute the created application. To do that after a successful build do it like you have done with manually compiling: type the name of the executable at the shell prompt
./mqtt_c8y
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900