Build fails in arduino but works in platform io

I am trying to compile a project based on this library that I adapted for arduino.

the library compiles fine in platform.io using these build flags

build_flags =
-D OPUS_BUILD
-D FIXED_POINT
-D OVERRIDE_OPUS_ALLOC
-D OVERRIDE_OPUS_FREE
-D VAR_ARRAYS
-D HAVE_CONFIG_H
-D OVERRIDE_OPUS_ALLOC_SCRATCH
-D DISABLE_FLOAT_API
-D OPUS_ARM_INLINE_EDSP
-D EMBEDDED_ARM
-D OPUS_ARM_ASM
-D'opus_alloc(x)=NULL'
-D'opus_free(x)=NULL'

I realise that Arduino doesn't really support build flags in libraries so I just made a header file with the defines and included that in every file in the library.

The build completes but the hardware will not run. It just locks up with a USB warning light flashing 9 times. ( a teensy error message warning USB connection is lost )

I checked the compile flags in platform IO and arduino in boards.txt and they appear to be the same.

ultimately arduino and platform.io both compile the code using GCC so I am not sure where to go next.

any ideas / things I can try would be much appreciated. the build defines are just telling the library to compile code in a certain way which is working as expected in platform.io

I'll ask this question on the teensy forum to as maybe its a hardware issue as the USB port disappears after upload. but it could it also be that arduino compiles code in a different way ?

With no code posted it is going to be difficult to provide any help

there is a link to the library above.

the only change is the inclusion of this header in every file of that library.

here is the project including the arduino main file OPUS_TX.ino that compiles / upload on the teensy 4.1 but then crashes the usb connection with 9 pulses of the red LED by the usb port

global_lib_defines.h has this code , which is included in every file in the project

#ifndef GOLBAL_LIB_DEFINES_H
#define GOLBAL_LIB_DEFINES_H

#ifdef __cplusplus
extern "C"
{
#endif


#define OPUS_BUILD
#define FIXED_POINT
#define OVERRIDE_OPUS_ALLOC 
#define OVERRIDE_OPUS_FREE 
#define VAR_ARRAYS 
#define HAVE_CONFIG_H 
#define OVERRIDE_OPUS_ALLOC_SCRATCH 
#define DISABLE_FLOAT_API 
#define OPUS_ARM_INLINE_EDSP 
#define EMBEDDED_ARM 
#define OPUS_ARM_ASM 
#define opus_alloc(x) NULL
#define opus_free(x) NULL



#ifdef __cplusplus
}
#endif

#endif

the global defines are passed to GCC compiler like this in platoform IO like this and it works.

build_flags =
    -D OPUS_BUILD
    -D FIXED_POINT
    -D OVERRIDE_OPUS_ALLOC
    -D OVERRIDE_OPUS_FREE
    -D VAR_ARRAYS
    -D HAVE_CONFIG_H
    -D OVERRIDE_OPUS_ALLOC_SCRATCH
    -D DISABLE_FLOAT_API
    -D OPUS_ARM_INLINE_EDSP
    -D EMBEDDED_ARM
    -D OPUS_ARM_ASM
    -D'opus_alloc(x)=NULL' 
    -D'opus_free(x)=NULL'

in case anyone ever reads this , I discovered there is possibly something broken in the latest teensyduino libs and/or newest release of arduino IDE. I just went back a few versions of both and everything builds and runs fine.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.