saniljhaveri / avr-project-ide

Automatically exported from code.google.com/p/avr-project-ide
0 stars 0 forks source link

Building with included headers in libraries fails #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open up some Arduino project with a library that includes headers. For
Example a KS0105 or TLC5940 Project where the library includes config files.
2. On compilation the compiler wont compile the included headers

--------------------------Build log----------------------
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT HardwareSerial.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/HardwareSerial.cpp"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT pins_arduino.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/pins_arduino.c"
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT Print.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/Print.cpp"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT WInterrupts.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/WInterrupts.c"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT wiring.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/wiring.c"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT wiring_analog.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/wiring_analog.c"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT wiring_digital.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/wiring_digital.c"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT wiring_pulse.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/wiring_pulse.c"
Execute: avr-gcc -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT wiring_shift.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/wiring_shift.c"
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT WMath.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/WMath.cpp"
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT Tlc5940.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/Tlc5940.cpp"
####Error: object file not created at D:\Arduino\output\Tlc5940.o
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT BasicAnimations.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/BasicAnimations.cpp"
####Error: object file not created at D:\Arduino\output\BasicAnimations.o
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT BasicUse.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/BasicUse.cpp"
####Error: object file not created at D:\Arduino\output\BasicUse.o
Execute: avr-g++ -I"D:\Arduino"
-I"C:\Users\Nachtwind\Desktop\AVRProjectIDE_Alpha18\arduino\core"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"
-I"C:\Users\Nachtwind\AppData\Roaming\AVRProjectIDE\temp"  -mmcu=atmega1280
-DF_CPU=16000000UL -Os -fpack-struct -fshort-enums -funsigned-char
-funsigned-bitfields -ffunction-sections -fdata-sections  -Wall -gdwarf-2
-std=gnu99 -MD -MP -MT arduino_temp_main.o  -c 
"C:/Users/Nachtwind/AppData/Roaming/AVRProjectIDE/temp/arduino_temp_main.cpp"
####Error: object file not created at D:\Arduino\output\arduino_temp_main.o
Execute: avr-gcc -mmcu=atmega1280 -Wl,-Map=testmitneueride.map
-Wl,--gc-sections -Os HardwareSerial.o pins_arduino.o Print.o WInterrupts.o
wiring.o wiring_analog.o wiring_digital.o wiring_pulse.o wiring_shift.o
WMath.o    -o testmitneueride.elf
c:/program files
(x86)/winavr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr51/crtm1280.o:(.ini
t9+0x0):
undefined reference to `main'
####Error: ELF file not created at D:\Arduino\output\testmitneueride.elf
Execute: rm -rf HardwareSerial.o pins_arduino.o Print.o WInterrupts.o
wiring.o wiring_analog.o wiring_digital.o wiring_pulse.o wiring_shift.o
WMath.o  libtestmitneueride.a HardwareSerial.d pins_arduino.d Print.d
WInterrupts.d wiring.d wiring_analog.d wiring_digital.d wiring_pulse.d
wiring_shift.d WMath.d  libtestmitneueride.a 
Build Failed
---------------------------------------------------------------

What is the expected output? What do you see instead?
I would love to see it work ;0)

What version of the product are you using? On what operating system?
Alpha26

Please provide any additional information below.
Added sketch source. Works in Arduino017

Original issue reported on code.google.com by mamage...@gmail.com on 4 Oct 2009 at 2:27

Attachments:

GoogleCodeExporter commented 8 years ago
the build log shows that avr-g++ attempted to compile your library
have you checked what actual compilation errors were given (Errors and Warnings 
tab
within the Output window)?
can you provide a link to this library?

Original comment by frank.zhao.main@gmail.com on 4 Oct 2009 at 11:18

GoogleCodeExporter commented 8 years ago
problem solved

actually found the library using google
i see the errors, NUM_TLCS and TLC_CHANNEL_TYPE are not declared

they are really not declared, i think in your code, you are supposed to specify 
which
one of two configuration files you wish to use, one of either tlc_config.h or
default_tlc_config.h

if you added the library in Arduino's environment, it included both 
tlc_config.h and
default_tlc_config.h on the top of your file, to get it working in my 
environment, add

#include "default_tlc_config.h"

to the top of the file, it has to go BEFORE "#include "Tlc5940.h"

you've also pointed out another issue for me, there was a regular expression in 
my
error and warning display routine that caused an error to be hidden, also i 
made a
mistake in the template xml i provided, both issues will be fixed in the next 
update

Original comment by frank.zhao.main@gmail.com on 4 Oct 2009 at 11:45

GoogleCodeExporter commented 8 years ago
go into configuration and remove the liba.a library, it was my mistake to 
include
that in the templates.xml
also delete the templates.xml so the updated one can be restored

Original comment by frank.zhao.main@gmail.com on 5 Oct 2009 at 12:14

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The answer was swift and understandable :0) 
Yet although i define my sketch now with 
/*
Includes
*/
#include "Arduino_Mega.h"
#include "chip_includes.h"
#include "tlc_config.h"
#include "Tlc5940.h"

at the beginning it fails, with the same errors, to build.
It may sound a bit selfish if i ask that, but let me explain ;0) 
Wouldnt it be possible to treat libraries the way the Arduino IDE does? 
The reason for that is that many libraries i know work on the smae principles 
and
hence this error would randomly occur, and that again and again as people, like 
me,
wouldnt be able to include libs the way it is needed and include them the way 
they
are used to ;0) 
I know this is a big deal of work, but as templates already assign an Arduino 
'type'
to the project you could also fake the according define and hence let the 
compiler
select the right headers for the library at hand. How much deeper the needed
modifications to the make project go i dont know, but i think it is all in all 
doable
and would spare you a great deal of 'errors' here..

Original comment by mamage...@gmail.com on 5 Oct 2009 at 7:20

GoogleCodeExporter commented 8 years ago
after i added the #include "tlc_config.h" and removed liba.a from the 
configuration,
it compiled fine, and the latest update I've uploaded fixed the bug that may 
have
hidden the error from you.

what arduino does is look into the folder for all the .h files in the library's
folder, and just include all of them, I disagree with this method because of 
exactly
how some of these libraries are designed

what is arduino_mega.h? what is chip_includes.h?

also, selecting the right headers based on the selected chip is not something 
that is
supposed to be done by an editor environment because it's already something 
designed
into avr-gcc, you can write header files that checks for the chip you are 
compiling
for by using

#ifdef __AVR_ATmega1280__
// code that only applies to arduino megas
#else
// code that never applies to arduino megas
#endif

inside the library, the "__AVR_ATmega1280__" is automatically defined by the
compiler, so in a sense, my editor has already done that for you when you apply 
the
template

this is way better than having separate header files, instead, you just have one
header file and organize it with the above pre-processor statements

Original comment by frank.zhao.main@gmail.com on 5 Oct 2009 at 3:18

GoogleCodeExporter commented 8 years ago
arduino doesn't treat libraries in a special way at all, but it does scan for 
the
ones you use so it knows which ones to compile. the only thing is that arduino 
has a
button that lets the user automatically add in all the header files. all you 
have to
do to simulate this is to just check which header files are in the library 
folder,
and include them manually, which is better, especially in your situation.

Original comment by frank.zhao.main@gmail.com on 5 Oct 2009 at 3:28

GoogleCodeExporter commented 8 years ago
for your reference, the defined macros are listed here

http://www.nongnu.org/avr-libc/user-manual/using_tools.html

Original comment by frank.zhao.main@gmail.com on 5 Oct 2009 at 3:34

GoogleCodeExporter commented 8 years ago
Interestering. The library you refer to doesnt exist here.. i will upload a pic 
of
the configuration.. 

By the way - the same errors occur on using #include "default_tlc_config.h"
 instead of #include "tlc_config.h"

Original comment by mamage...@gmail.com on 9 Oct 2009 at 3:43

Attachments:

GoogleCodeExporter commented 8 years ago
weird, i had no problems compiling a sketch with that library a few days ago

this is another reason why i think arduino has a bad design... the utilities 
folder
within a library is supposed to be treated as though it is in the same folder 
as the
library, this breaks portability completely, almost making arduino libraries 
useless
for normal C and C++ projects

Original comment by frank.zhao.main@gmail.com on 9 Oct 2009 at 4:46

GoogleCodeExporter commented 8 years ago
Wonderful!! Version32 did solve the problem :0)
It even seems like i can use my old Arduino codes without any change except 
telling
the compiler the 'new' functions on top of the file - but besides that - 
perfect!

Original comment by mamage...@gmail.com on 10 Oct 2009 at 8:25

GoogleCodeExporter commented 8 years ago
what do you mean by that? i just checked and function prototype generation 
still works.

Original comment by frank.zhao.main@gmail.com on 10 Oct 2009 at 5:17

GoogleCodeExporter commented 8 years ago
I mean that i dont have to include any other headers than i have to with the 
Arduino
ide - so in the end there seems to be a 99% compatibility now. The only 
difference to
th Arduino ide is, that you have to declare the names of functions 'below' 
loop() at
the top of the file.

Original comment by mamage...@gmail.com on 11 Oct 2009 at 9:44

GoogleCodeExporter commented 8 years ago
you shouldn't have to, weird, i can put my functions anywhere i want, above the
caller, below, from another file, etc, and never have to write the prototype

go into the temp folder in your appdata folder and check the 
arduino_temp_main.cpp file
the function prototypes should be added for you

my code should work identical to how arduino does it

Original comment by frank.zhao.main@gmail.com on 11 Oct 2009 at 3:32

GoogleCodeExporter commented 8 years ago

Original comment by frank.zhao.main@gmail.com on 16 Oct 2009 at 7:26