speex - undefined reference
-
Hello,
#include "speex/speex.h"
#include/*The frame size in hardcoded for this sample code but it doesn't have to be*/
#define FRAME_SIZE 160
int main(int argc, char **argv)
{
char *inFile;
FILE *fin;
short in[FRAME_SIZE];
float input[FRAME_SIZE];
char cbits[200];
int nbBytes;
/*Holds the state of the encoder*/
void *state;
/*Holds bits so they can be read and written to by the Speex routines*/
SpeexBits bits;
int i, tmp;/*Create a new encoder state in narrowband mode*/
state = speex_encoder_init(&speex_nb_mode);/*Set the quality to 8 (15 kbps)*/
tmp=8;
speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp);inFile = argv[1];
fin = fopen(inFile, "r");/*Initialization of the structure that holds the bits*/
speex_bits_init(&bits);
while (1)
{
/*Read a 16 bits/sample audio frame*/
fread(in, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
/*Copy the 16 bits values to float so Speex can work on them*/
for (i=0;i<frame_size;i++)>
input[i]=in[i];/\*Flush all the bits in the struct so we can encode a new frame\*/ speex\_bits\_reset(&bits); /\*Encode the frame\*/ speex\_encode(state, input, &bits); /\*Copy the bits to an array of char that can be written\*/ nbBytes = speex\_bits\_write(&bits, cbits, 200); /\*Write the size of the frame first. This is what sampledec expects but it's likely to be different in your own application\*/ fwrite(&nbBytes, sizeof(int), 1, stdout); /\*Write the compressed data\*/ fwrite(cbits, 1, nbBytes, stdout);
}
/*Destroy the encoder state*/
speex_encoder_destroy(state);
/*Destroy the bit-packing struct*/
speex_bits_destroy(&bits);
fclose(fin);
return 0;
}This libs are include Libs: libspeex.lib und libspeexdsp.lib But my Compiler Say: H:\speex\main.cpp|21|undefined reference to `speex_nb_mode'| What is the mistake?
-
Hello,
#include "speex/speex.h"
#include/*The frame size in hardcoded for this sample code but it doesn't have to be*/
#define FRAME_SIZE 160
int main(int argc, char **argv)
{
char *inFile;
FILE *fin;
short in[FRAME_SIZE];
float input[FRAME_SIZE];
char cbits[200];
int nbBytes;
/*Holds the state of the encoder*/
void *state;
/*Holds bits so they can be read and written to by the Speex routines*/
SpeexBits bits;
int i, tmp;/*Create a new encoder state in narrowband mode*/
state = speex_encoder_init(&speex_nb_mode);/*Set the quality to 8 (15 kbps)*/
tmp=8;
speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp);inFile = argv[1];
fin = fopen(inFile, "r");/*Initialization of the structure that holds the bits*/
speex_bits_init(&bits);
while (1)
{
/*Read a 16 bits/sample audio frame*/
fread(in, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
/*Copy the 16 bits values to float so Speex can work on them*/
for (i=0;i<frame_size;i++)>
input[i]=in[i];/\*Flush all the bits in the struct so we can encode a new frame\*/ speex\_bits\_reset(&bits); /\*Encode the frame\*/ speex\_encode(state, input, &bits); /\*Copy the bits to an array of char that can be written\*/ nbBytes = speex\_bits\_write(&bits, cbits, 200); /\*Write the size of the frame first. This is what sampledec expects but it's likely to be different in your own application\*/ fwrite(&nbBytes, sizeof(int), 1, stdout); /\*Write the compressed data\*/ fwrite(cbits, 1, nbBytes, stdout);
}
/*Destroy the encoder state*/
speex_encoder_destroy(state);
/*Destroy the bit-packing struct*/
speex_bits_destroy(&bits);
fclose(fin);
return 0;
}This libs are include Libs: libspeex.lib und libspeexdsp.lib But my Compiler Say: H:\speex\main.cpp|21|undefined reference to `speex_nb_mode'| What is the mistake?
Your variable speex_nb_mode is never defined. You first have to define a variable before being able to use it (for instance you are passing its address to the speex_encoder_init function and the variable doesn't even exist).
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Hello,
#include "speex/speex.h"
#include/*The frame size in hardcoded for this sample code but it doesn't have to be*/
#define FRAME_SIZE 160
int main(int argc, char **argv)
{
char *inFile;
FILE *fin;
short in[FRAME_SIZE];
float input[FRAME_SIZE];
char cbits[200];
int nbBytes;
/*Holds the state of the encoder*/
void *state;
/*Holds bits so they can be read and written to by the Speex routines*/
SpeexBits bits;
int i, tmp;/*Create a new encoder state in narrowband mode*/
state = speex_encoder_init(&speex_nb_mode);/*Set the quality to 8 (15 kbps)*/
tmp=8;
speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp);inFile = argv[1];
fin = fopen(inFile, "r");/*Initialization of the structure that holds the bits*/
speex_bits_init(&bits);
while (1)
{
/*Read a 16 bits/sample audio frame*/
fread(in, sizeof(short), FRAME_SIZE, fin);
if (feof(fin))
break;
/*Copy the 16 bits values to float so Speex can work on them*/
for (i=0;i<frame_size;i++)>
input[i]=in[i];/\*Flush all the bits in the struct so we can encode a new frame\*/ speex\_bits\_reset(&bits); /\*Encode the frame\*/ speex\_encode(state, input, &bits); /\*Copy the bits to an array of char that can be written\*/ nbBytes = speex\_bits\_write(&bits, cbits, 200); /\*Write the size of the frame first. This is what sampledec expects but it's likely to be different in your own application\*/ fwrite(&nbBytes, sizeof(int), 1, stdout); /\*Write the compressed data\*/ fwrite(cbits, 1, nbBytes, stdout);
}
/*Destroy the encoder state*/
speex_encoder_destroy(state);
/*Destroy the bit-packing struct*/
speex_bits_destroy(&bits);
fclose(fin);
return 0;
}This libs are include Libs: libspeex.lib und libspeexdsp.lib But my Compiler Say: H:\speex\main.cpp|21|undefined reference to `speex_nb_mode'| What is the mistake?
-
you have to add libspeex.lib libspeexdsp.lib into the project setting ->link->object/library modules blank
a beginner
The whole time both libarys are include in the speex projekt. If i dont link it, there were more errors like this one. I think &speex_nb_mode is not difine in the both libs?
-
The whole time both libarys are include in the speex projekt. If i dont link it, there were more errors like this one. I think &speex_nb_mode is not difine in the both libs?
Did you read my reply ? speex_nb_mode is a variable, so you should declare it somewhere. It is like using an integer, you first have to declare it before using it. Is this variable supposed to be declared as a global variable in your library ? What is the type of this variable ? I am pretty sure you are missing the point here and simply forgot to declare the variable and blame it on the library :)
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Did you read my reply ? speex_nb_mode is a variable, so you should declare it somewhere. It is like using an integer, you first have to declare it before using it. Is this variable supposed to be declared as a global variable in your library ? What is the type of this variable ? I am pretty sure you are missing the point here and simply forgot to declare the variable and blame it on the library :)
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++hmm the docu:
5.1.4.10 void speex_encoder_init (const SpeexMode mode) Returns a handle to a newly created Speex encoder state structure. For now, the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes may be added. Note that for now if you have more than one channels to encode, you need one state per channel. Parameters: mode The mode to use (either speex_nb_mode or speex_wb.mode) Returns: A newly created encoder state or NULL if state allocation fails
The error in VC++08;failsextry2.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_speex_nb_mode".
I think it isnt a variable. Ah, in speex.h
/**
* Returns a handle to a newly created Speex encoder state structure. For now,
* the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes
* may be added. Note that for now if you have more than one channels to
* encode, you need one state per channel.
*
* @param mode The mode to use (either speex_nb_mode or speex_wb.mode)
* @return A newly created encoder state or NULL if state allocation fails
*/
void *speex_encoder_init(const SpeexMode *mode);modified on Tuesday, February 3, 2009 9:41 AM