On Sat, Apr 13, 2002 at 02:37:33PM +1000, David Collett wrote:
> I am writing a "virtual cdplayer" application, that plays tracks
from my
> cd backups, which are stored as a .flac file and a cdrwin style .cue
> file. Anyway enough of that, onto the problem..
>
> I wish to use C++ for my program, but when I try to compile it with g++
> I get the following types of errors:
>
> /home/dave/development/splitimg/splitimg.cpp:153: undefined reference to
> `FLAC__file_decoder_new(void)'
> /home/dave/development/splitimg/splitimg.cpp:154: undefined reference to
> `FLAC__file_decoder_set_md5_checking(FLAC__FileDecoder const *, int)'
>
> and so on, you get the idea... its not linking to libFLAC :(
> my compile line is:
> g++ -g -o splitimg splitimg.cpp -lao -ldl -lFLAC -lm
>
> What is going wrong here, can I use libFLAC in C++ ?
The FLAC header files need to use:
#ifdef __cplusplus
extern "C" {
#endif
[everything]
#ifdef __cplusplus
}
#endif
So that they can be used from C++ as well as C.
You can temporarily work around the problem by using extern "C" around
your
#include of the FLAC headers, but this is a bug in FLAC that should be
fixed. Fortunately, the fix is easy.
--
- mdz