rajan
rajan

Reputation: 13

Getting errors when compiling code using makefile. Works using console

I am getting compilation errors when building my project with a makefile which I don't see when building using console.

I am using the prebuilt GNU toolchain for PowerPC.

Here is my makefile,

GCC_Assembler = powerpc-eabi-as
GCC_Compiler  = powerpc-eabi-gcc

Directory_Application :=$(argument)/Source_Files
Directory_Bootloader :=$(argument)/Source_Files
Directory_RAMBootloader :=$(argument)/Source_Files

Application_Source_Files := $(wildcard $(Directory_Application)/*.C)
Application_Source_Files_Objecs=$(Application_Source_Files:.C=.O)


default:  Build_Application
all:   Build_Application

Build_Application: $(Application_Source_Files_Objecs)


$(Application_Source_Files_Objecs) : %.O: %.C
$(GCC_Compiler)  -c $<   -o $@ -O1  -Wall -Wfatal-errors

It builds without errors when I try to build it using these commands.

CD %WORKSPACE%\Source Files
powerpc-eabi-gcc    debug.c       -c -odebug.o    -O1 -Wall -Wfatal-errors
powerpc-eabi-gcc    io.c          -c -oio.o       -O1 -Wall -Wfatal-errors
...
...

So, when building using makefile, I get an error for a function that is not declared correctly. See the image below

Error( Makefile )

/Debug.C: infunction 'void display_task_table()':
/Debug.C:627:18: error: 'task_wait' was not declared in this scope
task_wait(100*2);

I only get warning for the same function when compiling without makefile.

Warning( Console )

Debug.C: in function 'display_task_table':
Debug.c:627:3: warning: implicit declaration of function 'task_wait' [-    Wimplicit-function-declaration]
task_wait(100*2);

I can fix the error by including the proper header file, but I would like to know why?

Please let me know if I need to include anything else

Upvotes: 0

Views: 494

Answers (1)

Luis Colorado
Luis Colorado

Reputation: 12708

Well, you are using .C extension when compiling with the Makefile, so the compiler is interpreting the file as a C++ source file and in C++, not having a prototype is an error (and only a warning in C) Just rewrite the line

$(Application_Source_Files_Objecs) : %.O: %.C

to

$(Application_Source_Files_Objecs) : %.o: %.c

and try again (and don't use an Operating System that doesn't distinguish case of letters :) <--- this was a joke, don't flame, please)

EDIT

Please, do the same with all the lines that specify .C and .O files also to .c and .o instead. The operating system doesn't bother with the case of characters, but make(1) and gcc(1) do.

Upvotes: 1

Related Questions