4

I need to decode pcm data to opus format. Therefore I want to include the opus source into my project, but I can't link the files. I downloaded the source file opus-1.1.tar.gz from here. In Qt Creator, I added all the files to my pro-file:

INCLUDEPATH += \
$$PWD/opus/opus/celt \
$$PWD/opus/opus/celt/arm \
$$PWD/opus/opus/celt/tests \
$$PWD/opus/opus/celt/x86 \
$$PWD/opus/opus/silk \
$$PWD/opus/opus/silk/arm \
$$PWD/opus/opus/silk/fixed \
$$PWD/opus/opus/silk/float \
$$PWD/opus/opus/include \
$$PWD/opus/opus/win32

// and here would come an abnormous listing of all c- and h-files of opus:
SOURCES += ... 
HEADERS += ... 

At compile time, I get a warning from stack_alloc.h

#if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK))
#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode."
#endif    

For example, USE_ALLOCA is defined in config.h in opus/win32. From what I've seen, the file config.h only gets included like this:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

But in none of the files shipped with the source I can find #define HAVE_CONFIG_H. Moreover, in the file config.h there is a #include "version.h". That file is also not delivered with the source. I really don't know how I can use the Opus-lib. This can't be that hard, but I do not find a running minimal example at all.

I am using Windows 8, mingw, and c++ but the library is c.

user2366975
  • 4,350
  • 9
  • 47
  • 87

1 Answers1

0

You can add -D VAR_ARRAYS to your compile command or define in a header file:

#define VAR_ARRAYS 1

When building with emscripten (WebAssembly), I had to add two following flags:

$ emcc -D VAR_ARRAYS -D OPUS_BUILD ...
anthumchris
  • 8,245
  • 2
  • 28
  • 53