cmrincon
Posts: 9
Joined: Thu May 24, 2018 7:39 pm

makefile problem (freeBSD)

Mon Oct 08, 2018 11:06 pm

Hi!
I have to make an executable for university but i'm not be able to link the objets files. It seems that the compiler can generate the objet file but the linker cant generate the executable because it generates an empty file.

The make log is:

Code: Select all

-------------- Clean: all in Fase1 (compiler: LLVM Clang Compiler)---------------

Executing clean command: make -f Makefile clean
rm -f main.o *core *~ *.bak fase1.depend
Cleaned "Fase1 - all"

-------------- Build: all in Fase1 (compiler: LLVM Clang Compiler)---------------

Checking if target is up-to-date: make -q -f Makefile all
Running command: make -f Makefile all
cc -O2 -pipe -std=c89 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -Wdeclaration-after-statement -Wformat -Wformat-security -Wuninitialized -Wconversion -Wredundant-decls -Wunreachable-code -g -I/usr/local/include -I /home/estudiante/Practica\2/Fase\ nueva -c main.c -o main.o
cc -o fase1 main.o antispam.o ops_timeval.o -O2 -pipe -std=c89 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -Wdeclaration-after-statement -Wformat -Wformat-security -Wuninitialized -Wconversion -Wredundant-decls -Wunreachable-code -g -I/usr/local/include -I /home/estudiante/Practica\2/Fase\ nueva  -L/usr/local/lib -L /home/estudiante/Practica\2/Fase\ nueva -llzo2
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 
And the makefile is:

Code: Select all


MIS_FUENTES = main.c

EJECUTABLE = fase1

MIS_OBJETOS = main.o
OBJETOS_PROPORCIONADOS = antispam.o ops_timeval.o

OBJETOS = $(MIS_FUENTES:C/\.[lyc]$/.o/g) $(OBJETOS_PROPORCIONADOS) $(MIS_OBJETOS)


SIST_OPE_CFLAGS = -std=c89 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -Wdeclaration-after-statement -Wformat -Wformat-security -Wuninitialized -Wconversion -Wredundant-decls -Wunreachable-code

DEBUG_CFLAGS = -g

LZO2_CFLAGS =-I/usr/local/include -I /home/estudiante/Practica\2/Fase\ nueva

LZO2_LDFLAGS = -L/usr/local/lib -L /home/estudiante/Practica\2/Fase\ nueva -llzo2

CFLAGS += $(SIST_OPE_CFLAGS) $(DEBUG_CFLAGS) $(LZO2_CFLAGS)

LDFLAGS += $(LZO2_LDFLAGS)

all: depend $(EJECUTABLE)

clean:;
	rm -f $(MIS_OBJETOS) *core *~ *.bak $(EJECUTABLE).depend

depend:;
	@$(CC) -E -MM $(MIS_FUENTES) > [email protected]

$(EJECUTABLE): $(OBJETOS)
	$(CC) -o [email protected] $> $(CFLAGS) $(LDFLAGS)

What is wrong? thanks you all.
Last edited by cmrincon on Tue Oct 09, 2018 10:53 am, edited 1 time in total.

Heater
Posts: 10291
Joined: Tue Jul 17, 2012 3:02 pm

Re: makefile problem

Tue Oct 09, 2018 4:03 am

First thing to do is to fix up your C code so as to get rid of all those compiler warnings.

cmrincon
Posts: 9
Joined: Thu May 24, 2018 7:39 pm

Re: makefile problem

Tue Oct 09, 2018 7:52 am

there are no errors..shouldn't compile it with warnings only?

Heater
Posts: 10291
Joined: Tue Jul 17, 2012 3:02 pm

Re: makefile problem

Tue Oct 09, 2018 8:08 am

cmrincon,
there are no errors..shouldn't compile it with warnings only?
Yes but:

Getting rid of all warnings is commonly regarded as "best practice".

Ignoring warnings can lead to many surprises and much head scratching.

Having warning messages in forums posts is "noise". Extra stuff that we have to read and detracts from your problem. People will be more inclined to read your post and try to help if they have less work to do. It's just polite to clean up your code first.

Does your Makefile actually produce the object files you expect?

cmrincon
Posts: 9
Joined: Thu May 24, 2018 7:39 pm

Re: makefile problem

Tue Oct 09, 2018 8:11 am

Heater wrote:
Tue Oct 09, 2018 8:08 am

Does your Makefile actually produce the object files you expect?
Yes it generates main.o, rest of objets are pre-compiled

i will solve all those warnings in a couple of hours...

cmrincon
Posts: 9
Joined: Thu May 24, 2018 7:39 pm

Re: makefile problem

Tue Oct 09, 2018 10:54 am

cmrincon wrote:
Tue Oct 09, 2018 8:11 am
i will solve all those warnings in a couple of hours...
Done

Heater
Posts: 10291
Joined: Tue Jul 17, 2012 3:02 pm

Re: makefile problem

Tue Oct 09, 2018 12:29 pm

Given that you have all the object files what happens if you run the last step of the build manually:

$ cc -o fase1 main.o antispam.o ops_timeval.o -O2 -pipe -std=c89 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -Wdeclaration-after-statement -Wformat -Wformat-security -Wuninitialized -Wconversion -Wredundant-decls -Wunreachable-code -g -I/usr/local/include -I /home/estudiante/Practica\2/Fase\ nueva -L/usr/local/lib -L /home/estudiante/Practica\2/Fase\ nueva -llzo2

Perhaps delete the executable, fase1, first.

cmrincon
Posts: 9
Joined: Thu May 24, 2018 7:39 pm

Re: makefile problem

Fri Oct 12, 2018 7:51 pm

Thanks you now it seems to work.

Heater
Posts: 10291
Joined: Tue Jul 17, 2012 3:02 pm

Re: makefile problem

Sat Oct 13, 2018 2:38 am

That's great.

Would be nice if you would say what the problem actually turned out to be and what you changed to fix it.

Ending a thread like this is like reading a detective novel only to find someone has torn out the last page!

cmrincon
Posts: 9
Joined: Thu May 24, 2018 7:39 pm

Re: makefile problem

Sun Oct 14, 2018 2:56 pm

I run the instruction in console as you said and i finally thought the makefile was not the problem. Actually i didn't change anything from the makefile.
I think that when i run the makefile, the OS didn't refresh the views and it showed me a empty output file when the output file was correctly generated.

I wasn't using raspian, and i don't know if this problem can happen in a raspian OS ( i was using freeBSD).

Sometimes the silliest problem is the most tough to tackle.

Return to “Other”