views:

180

answers:

6

Hi,

Here is my makefile http://pastie.org/1104332. I am trying to compile different .c files and .s files (assembly files) from different sub directories into E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/ then the linker should link all the .o files from the build directory (E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680) into a file named mfg-sample-app.out. When I run the makefile which I posted above then the compiler compiles all the source files into object files in the build directory but the linker can not open the object files because its not looking for them in the build directory which is E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680. I dont know how why the linker does not look there? that is the error I get:

E:\IARSystems\EmbeddedWorkbench5.4Evaluation\arm\bin\ilinkarm.exe"      -o E:/e
m35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample-app.out --
map E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample-ap
p.map --log initialization,modules,sections,veneers --log_file E:/em35x/build/mf
g-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample-app.log --config E:/em3
5x/app/mfglib/ewb-em357/../../../hal/micro/cortexm3/em35x/em357/iar-cfg.icf --di
ag_suppress Lp012 --entry halEntryPoint  E:/em35x/build/alarm-library-cortexm3-i
ar-em357-em3xx/alarm-library.a E:/em35x/build/binding-table-stub-library-cortexm
3-iar-em357-em3xx/binding-table-stub-library.a  E:/em35x/build/cbke-stub-library
-cortexm3-iar-em357-em3xx/cbke-stub-library.a E:/em35x/build/end-device-bind-stu
b-library-cortexm3-iar-em357-em3xx/end-device-bind-stub-library.a  E:/em35x/buil
d/hal-library-cortexm3-iar-em357-em3xx/hal-library.a E:/em35x/build/mfglib-libra
ry-cortexm3-iar-em357-em3xx/mfglib-library.a  E:/em35x/build/security-library-co
re-cortexm3-iar-em357-em3xx/security-library-core.a E:/em35x/build/security-libr
ary-link-keys-stub-cortexm3-iar-em357-em3xx/security-library-link-keys-stub.a E:
/em35x/build/zigbee-pro-stack-cortexm3-iar-em357-em3xx/zigbee-pro-stack.a E:/em3
5x/app/mfglib/mfg-sample.o E:/em35x/hal/ember-configuration.o E:/em35x/hal/micro
/cortexm3/adc.o E:/em35x/hal/micro/cortexm3/bootloader-interface-app.o E:/em35x/
hal/micro/cortexm3/bootloader-interface-standalone.o E:/em35x/hal/micro/cortexm3
/bootloader-interface.o E:/em35x/hal/micro/cortexm3/button.o E:/em35x/hal/micro/
cortexm3/buzzer.o E:/em35x/hal/micro/cortexm3/cstartup-iar-common.o E:/em35x/hal
/micro/cortexm3/diagnostic.o E:/em35x/hal/micro/cortexm3/led.o E:/em35x/hal/micr
o/cortexm3/mfg-token.o E:/em35x/hal/micro/cortexm3/micro-common.o E:/em35x/hal/m
icro/cortexm3/micro.o E:/em35x/hal/micro/cortexm3/sleep.o E:/em35x/hal/micro/cor
texm3/token-def.o E:/em35x/hal/micro/cortexm3/token.o E:/em35x/hal/micro/cortexm
3/uart.o E:/em35x/hal/micro/generic/crc.o E:/em35x/hal/micro/generic/endian.o E:
/em35x/hal/micro/generic/mem-util.o E:/em35x/hal/micro/generic/random.o E:/em35x
/hal/micro/generic/sim-eeprom.o E:/em35x/app/util/serial/cli.o E:/em35x/app/util
/serial/serial.o E:/em35x/hal/micro/cortexm3/em35x/mpu.o E:/em35x/hal/micro/cort
exm3/faults.o E:/em35x/hal/micro/cortexm3/isr-stubs.o

   IAR ELF Linker V5.50.5.51995/W32 for ARM
   Copyright (C) 2007-2010 IAR Systems AB.
Fatal error[Li001]: could not open file "E:\em35x\app\mfglib\mfg-sample.o"
Fatal error detected, aborting.
make: *** [mfg-sample-app.out] Error 3

(first it compiles the source files but at the end it cannot find the object files in the build folder)

Now after I delete line 70 from the makefile which is

OBJ = $(SRC:.c=.o) E:/em35x/hal/micro/cortexm3/faults.o E:/em35x/hal/micro/cortexm3/isr-stubs.o

then the linker can find the previous compiled object files in the build directory and creates the .out file. And if I manually delete all the object files from the build directory (which the compiler created previously) and run the makefile again (line 70 is still deleted) then I get this error:

$ make
make: *** No rule to make target `E:/em35x/build/mfg-sample-app-cortexm3-iar-em3
57-em3xx-dev0680/mfg-sample.o', needed by `mfg-sample-app.out'.  Stop.

And if I add line 70 again which is :

OBJ = $(SRC:.c=.o) E:/em35x/hal/micro/cortexm3/faults.o E:/em35x/hal/micro/cortexm3/isr-stubs.o

then it compiles again but does not link because it cannot open the object files. (The first mentioned error again)

I dont know what I am doing wrong. I have tried many things but cannot find my problem.

Thanks

EDIT: I am using GNU Make 3.81

have changed the second-to-last line to:

$(END_DIR)/%.o : %.c

and I also made changes to VPATH as suggested by Gilles but no luck.

Now I get this erorr:

$ make
make: *** No rule to make target `E:/em35x/build/mfg-sample-app-cortexm3-iar-em3
57-em3xx-dev0680/mfg-sample.o', needed by `mfg-sample-app.out'.  Stop.

It is not compiling any .c file into a .o file

EDIT: Beta, I will be able to test you lines on Monday. I will then report the results, I want to resolve this issue it is driving me crazy. Thanks

EDIT:

Hi Beta,

I am still getting the same error with the code you suggested. This is the error, if mfg-sample.o is not in the build folder (E:/em35x/build/mfg-sample-app-cortexm3-iar-em3 57-em3xx-dev0680) :

tjoyia@TJ-PC /e/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680
$ make
make: *** No rule to make target `E:/em35x/build/mfg-sample-app-cortexm3-iar-em3
57-em3xx-dev0680/mfg-sample.o', needed by `mfg-sample-app.out'.  Stop.

But if mfg-sample.o already exists in the build folder (after I complied mfg-sample.c to mfg-sample.o) then I get this message:

tjoyia@TJ-PC /e/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680
$ make
found E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample.
o, making mfg-sample-app.out

EDIT:

Hi Beta, Yes, that worked.

I got this message:

tjoyia@TJ-PC /e/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680
$ make
found E:/em35x/app/mfglib/mfg-sample.c, making E:/em35x/build/mfg-sample-app-cor
texm3-iar-em357-em3xx-dev0680/mfg-sample.o
found E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample.
o, making mfg-sample-app.out

So, what should I do now in my original makefile? I want to compile my whole project and link the object files.(all my .c files in different path locations into the build folder and then the linker should link the previous created .o files into the .out file)

EDIT:

0 down vote accept

Hi Beta,

Ok I got it working, but what about the two .s79 files how I can get them also compiled into object files in the build directory? Why is VPATH not working and I think my dependcy file creation (.d) is not invoked how I can get the invoked. I want all the .h files (#include statements in the source files) get automatically recognized and depend on the object file.

And after that I want to convert the .out files but its not getting invoked.

Here is the problem:

Do you know how I could add this to my makefile:

ielftool.exe --srec --verbose E:\em35x\build\mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680\mfg-sample-app.out E:\em35x\build\mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680\mfg-sample-app.s37

It should convert the mfg-sample-app.out file into a mfg-sample-app.s37 after the .out file is created/linked from the object files.

A: 
Beta
have changed the link. Now it points to the makefile. Please look into it
ATJ
I must use this compiler for the projects in the special flag options.
ATJ
It only builds the the objects when line 70 is not ommited and overrides the previous OBJ variable in the makefile. When I ommit line 70 and use the OBJ variable before line 70 then it links the objects (if they are already built in the build directory) if I delete them then it gives the error which I mentioned in the second part of my question
ATJ
I am using GNU Make 3.81
ATJ
will be able to test it on Monday.Thanks
ATJ
but why is VPATH not working?
ATJ
and what about the .s79 files?
ATJ
A: 

You have two definitions of OBJ. One explicitly lists all of the objects and says they are in the END_DIR, but there's no rule to build an object file in one place from a source file in a different directory. The second rule uses the source files and replaces .c with .o (and the object files would be in the same directory as the source).

After you deleted the second rule, make used the first definition to identify where the object files should be for linking, but didn't know how to generate them. This explains the second error. To fix it, either modify the compilation rule to place the object files in a different directory, or use use the rule on line 70 that says they are in the same place as the source.

It's not clear why the first pass didn't work, but I'd recommend taking out the generation and inclusion of the dependence files (.d) until the compilation is working. I've found that it's far more useful to build them as a side effect of compilation than to create them explicitly. If they don't exist, then you haven't compiled anything and have to do a complete build anyway.

0x4b
I dont know what you mean exactly? What should I do? What I want is to compile the source files (which are in different subdirectories) in the build folder (object files). Then the linker should link all the object files from the build folder into a .out file.
ATJ
taking out the generation and inclusion of the dependence files (.d) did not help either.
ATJ
A: 

The linker is doing exactly what it's told: it's told to link "E:\em35x\app\mfglib\mfg-sample.o", which doesn't exist.

There is a problem in the definition of VPATH in the makefile: : is used both as the DOS/Windows drive indicator and as the path separator. On Windows, you must replace : by ; or by blanks. (This might break compatibility with other unix implementations of make, which is probably why the author of the script that generated this (part of the) makefile used :.)

VPATH = E:/em35x/app/mfglib/ E:/em35x/hal/ E:/em35x/hal/micro/cortexm3/ E:/em35x/hal/micro/generic/ E:/em35x/app/util/serial/ E:/em35x/hal/micro/cortexm3/ E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/
Gilles
but mfg-sample.o is in E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/How can I tell the linker to link E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample.o
ATJ
@ATJ: That's what the person who wrote the makefile intended to happen, with the `VPATH` feature. `VPATH` tells `make` to look for dependencies in the indicated directories in addition to the current directory (look it up in the `make` manual for more information). Try the change I suggest, it should work provided there isn't another bug in the makefile.
Gilles
sorry it its not working with that change either
ATJ
A: 

have changed the second-to-last line to:

$(END_DIR)/%.o : %.c

and I also made changes to VPATH as suggested by Gilles but no luck.

Now I get this erorr:

$ make
make: *** No rule to make target `E:/em35x/build/mfg-sample-app-cortexm3-iar-em3
57-em3xx-dev0680/mfg-sample.o', needed by `mfg-sample-app.out'.  Stop.

It is not compiling any .c file into a .o file

ATJ
A: 

Hi Beta,

I am still getting the same error with the code you suggested. This is the error, if mfg-sample.o is not in the build folder (E:/em35x/build/mfg-sample-app-cortexm3-iar-em3 57-em3xx-dev0680) :

tjoyia@TJ-PC /e/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680
$ make
make: *** No rule to make target `E:/em35x/build/mfg-sample-app-cortexm3-iar-em3
57-em3xx-dev0680/mfg-sample.o', needed by `mfg-sample-app.out'.  Stop.

But if mfg-sample.o already exists in the build folder (after I complied mfg-sample.c to mfg-sample.o) then I get this message:

tjoyia@TJ-PC /e/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680
$ make
found E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/mfg-sample.
o, making mfg-sample-app.out
ATJ
You don't have put this in as an answer; editing the post is sufficient.
Beta
A: 

Hi Beta,

Do you know how I could add this to my makefile:

ielftool.exe --srec --verbose E:\em35x\build\mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680\mfg-sample-app.out E:\em35x\build\mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680\mfg-sample-app.s37 

It should convert the mfg-sample-app.out file into a mfg-sample-app.s37 after the .out file is created/linked from the object files.

ATJ