C 无法在ubuntu上编译libsndfile代码
这是我的第一篇文章。 我需要为我的项目操纵音频,所以我决定使用libsnfile。 我已经安装了它,但当我试图用C 无法在ubuntu上编译libsndfile代码,c,ld,pkg-config,libsndfile,C,Ld,Pkg Config,Libsndfile,这是我的第一篇文章。 我需要为我的项目操纵音频,所以我决定使用libsnfile。 我已经安装了它,但当我试图用gcc somefile.c或gcc`pkg config sndfile`somefile.c编译任何.c程序时,它会给我“未定义”错误 /tmp/ccGTKZdy.o:En la función“转换为文本”: sndfile to text.c:(.text+0x193):在定义中引用'sf_readf_float' /tmp/ccGTKZdy.o:En la función‘m
gcc somefile.c
或gcc`pkg config sndfile`somefile.c
编译任何.c程序时,它会给我“未定义”错误
/tmp/ccGTKZdy.o:En la función“转换为文本”:
sndfile to text.c:(.text+0x193):在定义中引用'sf_readf_float'
/tmp/ccGTKZdy.o:En la función‘main’:
sndfile to text.c:(.text+0x37a):在定义中引用“sf_open”
sndfile to text.c:(.text+0x3a7):在定义中引用“sf_strerror”
sndfile to text.c:(.text+0x3e1):在定义中引用“sf_strerror”
sndfile to text.c:(.text+0x45f):在定义中引用“sf_close”
未定义任何“sf_u…”函数。
我已经读到,我可能必须链接到图书馆,但idk如何。帮助。仅调用
pkg config sndfile
是不够的。应该是:
gcc somefile.c "$(pkg-config --libs --cflags sndfile)"
现在,在命令替换中,建议将$()
置于背景符号之上:
还请记住在程序中包含libsndfile头:
#include <sndfile.h>
谢谢你的回答,但没用。仍然给出相同的错误。我还能做什么?你确定你已经安装了sndfile吗?
pkg-config--libs--cflags-sndfile
说了什么?我不确定它是否安装完成。该命令返回:-I/usr/local/include-L/usr/local/lib-lsndfileok,因此它应该可以工作。张贴您所执行的所有确切步骤以及收到的错误消息。顺便说一句,将您的语言环境更改为英语。好的。我刚换了英语。我所做的是。1.进入libsndfile2中的examples文件夹。打开终端并键入export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 3。尝试使用gcc“$(pkg config--libs--cflags sndfile)”-Wall-Wextra-pedantic generate.c编译内部的任何.c
gcc -Wall -Wextra -pedantic somefile.c "$(pkg-config --libs --cflags sndfile)"