1

libsndfile を使用しようとしています。私はg ++もあまり得意ではありません。libsndfile のインストール方法は make install のようです。本当にできるので、ディレクトリにコンパイルしました。

ここでチュートリアルをコンパイルしようとしていました:
http://parumi.wordpress.com/2007/12/16/how-to-write-wav-files-in-c-using-libsndfile/

次のことを試すと:

g++  -Isrc/ test.c

私は得る:

/tmp/ccq5fhbT.o: In function SndfileHandle::SndfileHandle(char const*, int, int, int, int)':
test.c:(.text._ZN13SndfileHandleC1EPKciiii[SndfileHandle::SndfileHandle(char const*, int, int, int, int)]+0xf4): undefined reference to sf_open'
/tmp/ccq5fhbT.o: In function SndfileHandle::write(float const*, long)':
test.c:(.text._ZN13SndfileHandle5writeEPKfl[SndfileHandle::write(float const*, long)]+0x27): undefined reference to sf_write_float'
/tmp/ccq5fhbT.o: In function SndfileHandle::SNDFILE_ref::~SNDFILE_ref()':
test.c:(.text._ZN13SndfileHandle11SNDFILE_refD1Ev[SndfileHandle::SNDFILE_ref::~SNDFILE_ref()]+0x20): undefined reference to sf_close'
collect2: ld returned 1 exit status

次のことをしようとすると:

g++ -lsndfile -Isrc/ test.c

私は得る

/usr/bin/ld: cannot find -lsndfile
collect2: ld returned 1 exit status

g++ を指定する必要があるスイッチがわかりません。

4

2 に答える 2

7

以下を使用してlibsndfileを構成およびインストールする場合:

./configure --prefix=$HOME/local
make
make install

次に、LD_LIBRARY_PATH変数を設定/変更する必要があります。

export $LD_LIBRARY_PATH=$HOME/local/lib

その後、でコンパイルします

g++ -I $HOME/local/include -L $HOME/local/lib -lsndfile testsnd.c -o  testsnd
于 2012-12-18T04:05:12.827 に答える
2

GNU/Linux Debian スクイーズでは、libsndfile1 ライブラリをインストールしましたが、プログラムは問題なくコンパイルされます。

# apt-get install libsndfile1-dev
$ g++ -w -o testsnd testsnd.c -lsndfile

パッケージ マネージャーを使用して、またはソース コードからライブラリをインストールする必要があります。

于 2012-12-18T00:14:40.827 に答える