Society of Robots - Robot Forum

Software => Software => Topic started by: jzaun on February 29, 2012, 12:10:39 AM

Title: webbotlib - error trying to compile
Post by: jzaun on February 29, 2012, 12:10:39 AM
Hello, I'm getting an error trying to compile the lib:

avr-gcc -DBUILDING_LIBRARY -Wall -Os -gdwarf-2 -std=gnu99 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields -mmcu=atmega328p -MMD -MP -MF"build/atmega328p/Audio/Text2Speech/phoneme2sound.d" -MT"build/atmega328p/Audio/Text2Speech/phoneme2sound.d" -c -o"build/atmega328p/Audio/Text2Speech/phoneme2sound.o" "Audio/Text2Speech/phoneme2sound.c"
In file included from Audio/Text2Speech/Text2Speech.h:105:0,
                 from Audio/Text2Speech/phoneme2sound.c:34:
Audio/Text2Speech/../../rprintf.h:109:1: error: unknown type name 'prog_char'
Audio/Text2Speech/phoneme2sound.c: In function 'phonemesToData':
Audio/Text2Speech/phoneme2sound.c:129:4: warning: passing argument 1 of 'rprintfProgStr' from incompatible pointer type [enabled by default]
Audio/Text2Speech/../../rprintf.h:109:6: note: expected 'const int *' but argument is of type 'const char *'
Audio/Text2Speech/phoneme2sound.c:168:4: warning: passing argument 1 of 'rprintfProgStr' from incompatible pointer type [enabled by default]
Audio/Text2Speech/../../rprintf.h:109:6: note: expected 'const int *' but argument is of type 'const char *'
make[1]: *** [build/atmega328p/Audio/Text2Speech/phoneme2sound.o] Error 1


I'm wondering if anyone else has run into this and know how to solve it.

Thanks,
Justin
Title: Re: webbotlib - error trying to compile
Post by: newInRobotics on February 29, 2012, 05:39:56 AM
Quote
Audio/Text2Speech/../../rprintf.h:109:1: error: unknown type name 'prog_char'
There is no definition for prog_char data type. I assume it's variable and not data type.

Quote
Audio/Text2Speech/../../rprintf.h:109:6: note: expected 'const int *' but argument is of type 'const char *'
You are trying to pass pointer to int rather than pointer to char.

Have You tried reading and understanding what error message says?  ;D
Title: Re: webbotlib - error trying to compile
Post by: jzaun on February 29, 2012, 10:51:34 AM
Yes, I have read the error, but I haven't coded anything yet. I just unzipped the library and typed make to rebuild it. I would have thought in a library there would be no errors, so I assume I'm doing something else wrong but not sure what.
Title: Re: webbotlib - error trying to compile
Post by: Webbot on February 29, 2012, 04:51:58 PM
What compiler version are you using - I'm guessing that they have changed some of the type casting behavior in the version (old or newer) that you are using compared to the one that I'm using.
Title: Re: webbotlib - error trying to compile
Post by: jzaun on February 29, 2012, 08:22:48 PM
Hi Webbot,

I'm using gcc-4.6.2 compiled from source. Is there a specific version I should be using?
Title: Re: webbotlib - error trying to compile
Post by: Webbot on March 01, 2012, 01:56:10 PM
I'm using WinAvr http://winavr.sourceforge.net/ (http://winavr.sourceforge.net/)

Suspect you may be a non-Windows person?

Is there a reason why you are re-compiling the libraries since they already come pre-compiled into .a library files ready for use?
Title: Re: webbotlib - error trying to compile
Post by: joe61 on March 01, 2012, 02:18:34 PM
I'm using gcc-4.6.2 compiled from source. Is there a specific version I should be using?

Did you apply the recommended patches before building?

Joe
Title: Re: webbotlib - error trying to compile
Post by: jzaun on March 01, 2012, 03:44:53 PM
Webbot,

Your right, I'm on a mac. There is no immediate need for me to recompile the library, though if there was a need to recompile in the future (adding support for hardware) it would be nice to know I could.

Joe,

I'm new to the avr (not to programming in general). In my quest to getting a working toolchain I was following the compile option listed here http://www.ladyada.net/learn/avr/setup-mac.html (http://www.ladyada.net/learn/avr/setup-mac.html) and there are not patched mentioned. I have read about gcc patches in other forums but no links to the patches as far as I could find. So at the moment I've got a gcc-4.6.2 stock compile for the avr.
Title: Re: webbotlib - error trying to compile
Post by: Webbot on March 01, 2012, 07:36:27 PM
The WinAvr release I'm using using is from Jan 2010 so will be way before 4.6.2. I'm guessing your later version has better/stricter type checking. I can look at the source to see if there is anything obviously wrong - but hard for me to check as it compiles fine in WinAvr ie - if I can't reproduce then its hard to fix. Equally its hard for me to upgrade since WinAvr wraps up lots of other stuff like CygWin etc for the Win platform.

However: since WebbotLib is open source, and you aren't new to development, then I also encourage you to have a look - and see if we can can come up with a solution that compiles on both platforms. If its just the the Text2speech thats giving the problem then try knocking it out of the build and lets see if there are other problems.
Title: Re: webbotlib - error trying to compile
Post by: jzaun on March 03, 2012, 02:54:52 AM
OK... I'm getting there.

First on the mac these 3 lines need to be added to libdefs.h, I added them right under your #if defined(_WINDOWS_) block. That allows for a large part of the library to compile. I tried to check for a define I could use but __APPLE__ isn't defined in my version of avr-gcc for some reason - still looking into why its not.

#undef PROGMEM
#define PROGMEM
#define prog_char

It is a little odd though as I need the #undef line or I get libdefs.h:101:0: warning: "PROGMEM" redefined [enabled by default] from it being defined in avrchain/include/avr/pgmspace.h but without those 2 lines or even just the #undef line the webbot wont compile.

The second issue thats going to be harder to fix is that I'm using a newer avr-libc than you. This mean that SIG_2WIRE_SERIAL has been poisoned and can no longer be used. I'm running into this with:

i2c_slave.c:106:5: error: attempt to use poisoned "SIG_2WIRE_SERIAL"

This forum post may or may not help: http://arduino.cc/forum/index.php?action=printpage;topic=92364.0 (http://arduino.cc/forum/index.php?action=printpage;topic=92364.0) but I'm not knowledgeable enough about avr yet to attempt to fix this. I am using avr-libc-1.8.0, I'm assuming your version is from early 2010 as well. I'm not sure if at compile time this can be #ifdefed to allow both versions of avr-libc to compile; but like I said I don't know enough yet to attempt to fix this.

My next step is going to be to skip over i2c and see if I can get the lib to complete the compile but that will have to wait till tomorrow.


Title: Re: webbotlib - error trying to compile
Post by: Webbot on March 04, 2012, 08:05:13 AM
What you could try is editing the makeone file and changing these lines:-
Code: [Select]
CFLAGS = -DBUILDING_LIBRARY -Wall -Os -gdwarf-2 -std=gnu99 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields
CPPFLAGS = -DBUILDING_LIBRARY -Wall -Os -gdwarf-2            -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields

to:

Code: [Select]
CFLAGS = -D__PROG_TYPES_COMPAT__ -D__AVR_LIBC_DEPRECATED_ENABLE__ -DBUILDING_LIBRARY -Wall -Os -gdwarf-2 -std=gnu99 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields
CPPFLAGS = -D__PROG_TYPES_COMPAT__ -D__AVR_LIBC_DEPRECATED_ENABLE__ -DBUILDING_LIBRARY -Wall -Os -gdwarf-2            -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields

and get rid of the lines you added to my libdefs.h
Then do a make clean (to clreat stuff out), followed by a make (to remake from scratch).

What looks like is happening from the links in your post:

The SIGNALs are no longer supported for interrupt routines ie should use ISR(TWI_vect) rather than ISR(SIG_2WIRE_SERIAL) - this should be sorted by adding the -D__AVR_LIBC_DEPRECATED_ENABLE__

The second issue is that you can now only use PROGMEM in variable declarations and not in type definitions - hence 'prog_char' is no longer supported - unless you specify the -D__PROG_TYPES_COMPAT__
Title: Re: webbotlib - error trying to compile
Post by: jzaun on March 07, 2012, 12:03:44 AM
We'll its a lot closer, I was able to get a full compile without errors. I did a fresh download and modified the makeone file with the two -D options. I still have to add the #define PROGMEM line though. Without it it still wouldn't compile. I did not have to add the #define prog_char line. I'm trying to google what PROGMEM is and see if there is a -D I can use to get it to compile without adding the line.
Title: Re: webbotlib - error trying to compile
Post by: Webbot on March 07, 2012, 01:27:27 PM
Are you using the Version 1 or Version 2 codestream of WebbotLib. Reason for asking is that the PROGMEM issue may be caused by using it in typedefs which Version 1 does - but Version 2 doesn't coz the C++ compiler didn't like it. NB You can still use Version 2 with C as well.
So try the Version 2 code stream, along with the makeone changes shown previously.
Title: Re: webbotlib - error trying to compile
Post by: jzaun on March 07, 2012, 05:58:02 PM
I'm using this link:
http://212.219.56.143/sites/download.sourceforge.net/pub/sourceforge/w/project/we/webbotavrclib/webbotavrclib-1.35.zip (http://212.219.56.143/sites/download.sourceforge.net/pub/sourceforge/w/project/we/webbotavrclib/webbotavrclib-1.35.zip)

was the largest version number I found in the directory.  If there is newer/better I'll use it :)

edit: I just looked there is a version2 directory there. I'll give that a try and let you know.

update:

source:
http://212.219.56.143/sites/download.sourceforge.net/pub/sourceforge/w/project/we/webbotavrclib/Version2/webbotavrclib-2.08.zip (http://212.219.56.143/sites/download.sourceforge.net/pub/sourceforge/w/project/we/webbotavrclib/Version2/webbotavrclib-2.08.zip)

makeone:
Code: [Select]
CFLAGS = -D__PROG_TYPES_COMPAT__ -D__AVR_LIBC_DEPRECATED_ENABLE__ -DBUILDING_LIBRARY -Wall -Os -gdwarf-2 -std=gnu99 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields
CPPFLAGS = -D__PROG_TYPES_COMPAT__ -D__AVR_LIBC_DEPRECATED_ENABLE__ -DBUILDING_LIBRARY -Wall -Os -gdwarf-2 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields

error:
Code: [Select]
In file included from Audio/Text2Speech/Text2Speech.h:107:0,
                 from Audio/Text2Speech/phonemeWriter.c:31:
Audio/Text2Speech/../../rprintf.h:100:1: warning: 'prog_char' is deprecated: prog_char type is deprecated. [-Wdeprecated-declarations]
avr-gcc -D__PROG_TYPES_COMPAT__ -D__AVR_LIBC_DEPRECATED_ENABLE__ -DBUILDING_LIBRARY -Wall -Os -gdwarf-2 -std=gnu99 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields -mmcu=atmega328p -MMD -MP -MF"build/atmega328p/Audio/Text2Speech/sound2noise.d" -MT"build/atmega328p/Audio/Text2Speech/sound2noise.d" -c -o"build/atmega328p/Audio/Text2Speech/sound2noise.o" "Audio/Text2Speech/sound2noise.c"
In file included from Audio/Text2Speech/Text2Speech.h:107:0,
                 from Audio/Text2Speech/sound2noise.c:29:
Audio/Text2Speech/../../rprintf.h:100:1: warning: 'prog_char' is deprecated: prog_char type is deprecated. [-Wdeprecated-declarations]
Audio/Text2Speech/sound2noise.c:46:16: error: variable 'SoundData' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
make[1]: *** [build/atmega328p/Audio/Text2Speech/sound2noise.o] Error 1
make: *** [atmega328p] Error 2

any other ideas?