我正在尝试使用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
Run Code Online (Sandbox Code Playgroud)
我明白了:
/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
Run Code Online (Sandbox Code Playgroud)
当我尝试执行以下操作时:
g++ -lsndfile -Isrc/ test.c
Run Code Online (Sandbox Code Playgroud)
我明白了
/usr/bin/ld: cannot find -lsndfile
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我不确定我需要给g ++什么开关.
如果使用以下命令配置和安装libsndfile:
./configure --prefix=$HOME/local
make
make install
Run Code Online (Sandbox Code Playgroud)
然后,您应该设置/修改LD_LIBRARY_PATH变量:
export $LD_LIBRARY_PATH=$HOME/local/lib
Run Code Online (Sandbox Code Playgroud)
然后用.编译
g++ -I $HOME/local/include -L $HOME/local/lib -lsndfile testsnd.c -o testsnd
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6424 次 |
| 最近记录: |