libmad编译及使用
㈠ makefile la 怎么指定
现有libmad交叉编译后安装于:/home/andy/share/libmad_install目录
现在应用程序miniplayer位于:/home/andy/share/mini_player目录
mini_player中的makefile里,怎么指定libmad库和mad.h头文件的路径呢?
1
指定 头文件用
-I /home/andy/share/mini_player
指定 库文件: -L 后面是具体的目录。
-L /home/andy/share/libmad_install
makefile如下,先编译完,拷到arm板上运行时提示:
/flac_app: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
这些lib我已经拷到板上的/lib里了,怎么会找不到
#
# Makefile for the CAMERA Application.
#
#以下是指定编译器路径
CC = /opt/armv6/codesourcery/bin/arm-none-linux-gnueabi-gcc
#以下是指定编译需要的头文件
CFLAGS = -g -Wall -O0 -I/home/andy/share/alsalib/include -I/home/andy/share/libmad_install/include
#以下是源文件
SRCS = main.c miniplayer_decode.c miniplayer_play.c
#以下是指定需要的库文件
LIBS = -L/home/andy/share/libmad_install/lib -lmad -L/home/andy/share/alsalib/lib -lasound
#以下是指定目标文件 所有当.c文件变成.o文件
OBJS = $(SRCS:.c=.o)
#以下是生成可执行文件
EXECUTABLE = flac_app
#make all 执行生成可执行文件
#1编译器 2编译选项 3输出 4生成的可执行文件 5需要的源文件 6需要当库文件
all:
$(CC) $(CFLAGS) -o $(EXECUTABLE) $(SRCS) $(LIBS)
#make clean 删除所有的.o文件 和生成的可以执行文件
clean:
rm -f $(OBJS) flac_app
makefile中的指定头文件,源文件
可以使用VPATH变量也可以使用vpath后者可以分类指定头文件源文件的搜索路径
记住这样指定的路径仅仅是makefile本身查找头文件源文件的路径
在执行makefile时,还要指定gcc/g++搜索头文件库文件的搜索路径
-L //指定库文件搜索路径
-ltest//指定使用的动态库/静态库
-I //指定搜索头文件的路径
㈡ 如何编译和使用开源库cryptLib,有人用过这
c++软件开发第三方库大全
1.boost
2.pthread windows下的posix线程实现
3.libcurl 开源网络爬虫库 阿里旺旺中使用到了
4.libeay32 OpenSSL Library
5.libtidy 解析htm的库
6.zlib
7.freetype c接口的type2字体处理库
8.libmad 编解码mp3的库
9.libogg,编解码ogg音频格式的库
10.libsnd 开源的编解码十多种音频格式的库
11.ffmpeg 音频视频处理的库
12.Freeimage,Cximage,Devil 这3个都是用来处理图形的库
13.libpng,libjpeg,....基本同上
14.angelscript 类似lua的脚本引擎 其脚本风格类似于标准c语言
15.flac/flac++编解码flac音频格式的库
16.tinyxml,rapidxml,libxml 关于xml解析方面的
17.luaplus,luabind涉及绑定lua和c++的库
18.ode,bullet 开源的物理引擎库
19.timidity可以把mid音频格式转化为wav格式的库
20.vlc类似ffmeg的库
21.zthread类型boost-thread,pthread的c++风格的多线程库
22.sigc++,sigslot信号插槽库 类型的有boost中的signal
23.SDL 简单的音频视频库
24.hge简单的使用ddraw的2维游戏小引擎
25.opencv开源的处理图形的库
26.mygui,cegui 游戏上使用的GUI系统
27.鬼火游戏引擎,Orge,都是开源的游戏中间件
28.Wxwidget开源的跨平台,类似MFC
29.QT ..
30.loki实验性质的c++库
31.ace网络通信库
32.fmod游戏音效引擎
33.sqlite 开源的桌面数据库
㈢ mplayer怎么使用
MPlayer是唯一支持P2P软件在线点播的播放器。
P2P点播:可在Vagaa、BT、电驴等软件中实现边下载边看。
1、低消耗:软件小、启动快,消耗内存和CPU非常少。
2、兼容多格式:几乎可以播放所有当前流行的所有视频格式。
http://www.mplayer.org.cn/
㈣ 如何在linux下安装madplay
这是我的安装的步骤
1、[root@bogon ~]# cd madplay/ cd到放软件的目录
2、[root@bogon madplay]# ls 这是我的cnds上面下载的软件,有4个
libid3tag-0.15.1b.tar.gz madplay-0.15.2b.tar.gz
libmad-0.15.1b.tar.gz zlib-1.1.4.tar.gz
3、[root@bogon madplay]# tar -zxvf zlib-1.1.4.tar.gz 解压zilb库
4、安装zilb库
[root@bogon madplay]# cd zlib-1.1.4 这个目录是刚才解压得到的
[root@bogon zlib-1.1.4]# make 我们要编译这个软件
[root@bogon zlib-1.1.4]# make install 编译并安装这个库
这下面是执行这个命令得到的结果,可以不看
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
cp libz.a /usr/local/lib
cd /usr/local/lib; chmod 755 libz.a
cd /usr/local/lib; if test -f libz.so.1.1.4; then \
rm -f libz.so libz.so.1; \
ln -s libz.so.1.1.4 libz.so; \
ln -s libz.so.1.1.4 libz.so.1; \
(ldconfig || true) >/dev/null 2>&1; \
fi
5、返回上级目录
[root@bogon ~]# cd madplay/
6、安装libid3tag-0.15.1b这个软件
[root@bogon madplay]# tar -zxvf libid3tag-0.15.1b.tar.gz
[root@bogon madplay]# cd libid3tag-0.15.1b
[root@bogon libid3tag-0.15.1b]# ./configure 使用它生成makefile文件
[root@bogon libid3tag-0.15.1b]#make 我们要编译这个软件
[root@bogon libid3tag-0.15.1b]#make install 我们要编译并安装这个软件
7、编译安装libmad-0.15.1b.tar.gz 执行库
[root@bogon madplay]# tar -zxvf libmad-0.15.1b.tar.gz
[root@bogon madplay]# cd libmad-0.15.1b
[root@bogon libmad-0.15.1b]# ./configure
做完上一步,我们要对Makefile进行修改,要不然会出错的
[root@bogon libmad-0.15.1b]# vi Makefile
将-fforce-mem选项干掉即可
[root@bogon libmad-0.15.1b]# make
[root@bogon libmad-0.15.1b]# make install
8、安装应用程序 madplay-0.15.2b
[root@bogon madplay]# tar -zxvf madplay-0.15.2b.tar.gz
[root@bogon madplay]# cd madplay-0.15.2b
做下面这两个是防止生成makefile文件提示少文件,你也可以不做下面这两个操作试一下就知道出什么错误了,下面编上号
(1)[root@bogon madplay]# vi /etc/ld.so.conf 编辑/etc/ld.so.conf文件在最后行加上/usr/local/lib 保存退出
(2)[root@bogon madplay]# ldconfig
[root@bogon madplay-0.15.2b]# ./configure
[root@bogon madplay-0.15.2b]# make
[root@bogon madplay-0.15.2b]# make install
这个软件算是装完了,这个是源代码包的安装,你也可以使用rpm包或deb包,只要网上能找到
还有就是./configure这个后面可以加上路径
例如./configure --prefix=这后面加路径,例如:./configure --prefix=/usr/local/madplay-0.15.2b
当然上面做出修改,一此配置文件就要做出修改
最后测试,
[root@bogon ~]# madplay /root/x.mp3 这是我虚拟机里面的mp3名字
下面是结果
MPEG Audio Decoder 0.15.2 (beta) - Copyright 漏 2000-2004 Robert Leslie et al.
Title: 仙剑问情
Copyright 漏 QqBoY.CoM
Artist: 萧人凤
Album: 仙剑奇侠传三·问情篇
Track: 01
Year: 2004
Encoder: QqBoY.CoM
Comment: 曲:骆集益
词:贾卓伦
唱:萧人凤
9707 frames decoded (0:04:13.5), +0.1 dB peak amplitude, 1 clipped sample
由于对中文件支持不太好,所以有此乱码了,希望对你有帮助
㈤ linux交叉编译libfad出现asm错误,不知道如何解决
没遇到过这个问题,我编译过libmad,是一个音频解码库。这个"asm",在Linux内核里表示跟CPU体系结构相关的东西。我猜测是不是这个libmad需要单独编译成ARM版本的库,然后再基于这个库编译。我之前编译播放器的时候就是需要单独编一个libmad。
以上只是个人推测,如果你找到问题所在,还请把编译方法讲一下,交流学习。
QQ:1138354321
㈥ 怎么使用libmad
所幸手里有Altera公司的一个工程,借助对该工程的分析、minimad.c中少的可怜的注释和网上搜索的Linux音频方面的相关知识,反复思考编码,总算把libmad库用起来了,现记录一下其使用方法,在帮助别人的同时也方便自己回头查询。在开始之前,最好先把mp3文件格式和Linux音频编程方面的知识先学习一下,不然后面有的东西可能听不懂,还有就是一定要熟悉Linux系统,后面的代码都是在linux系统中用gcc编译的,在Windows下不能用的。首先看下面几个问题,这也是我一开始最迷惑的,弄明白这几个问题了,也就对libmad库的使用相当熟悉了: minimad.c怎么编译?编译后怎么运行?运行时的输入输出分别是什么,或者说运行时什么效果?怎样播放minimad输出的数据?或者说怎么播放解码后的数据?minimad运行时,mp3数据来源是标准输入,能不能改为从文件中读入数据?该怎么改?minimad运行时首先要将整个mp3文件读入内存,能不能改成边解码边读入的形式,比如每次读入16K,解码完再读入16K,而又不影响播放的连贯性,这样可以节省内存开销,方便在嵌入式系统中使用;怎样用libmad做一个简单的mp3播放器? 一个一个来讲吧。 #include #include #include #include #include #include #include #include #include #include "mad.h" #define BUFSIZE 8192 /* * This is a private message structure. A generic pointer to this structure * is passed to each of the callback functions. Put here any data you need * to access from within the callbacks. */ struct buffer { FILE *fp; /*file pointer*/ unsigned int flen; /*file length*/ unsigned int fpos; /*current position*/ unsigned char fbuf[BUFSIZE]; /*buffer*/ unsigned int fbsize; /*indeed size of buffer*/ }; typedef struct buffer mp3_file; int soundfd; /*soundcard file*/ unsigned int prerate = 0; /*the pre simple rate*/ int writedsp(int c) { return write(soundfd, (char *)&c, 1); } void set_dsp() { int format = AFMT_S16_LE; int channels = 2; soundfd = open("/dev/dsp", O_WRONLY); ioctl(soundfd, SNDCTL_DSP_SETFMT, &format); ioctl(soundfd, SNDCTL_DSP_CHANNELS, &channels); } /* * This is perhaps the simplest example use of the MAD high-level API. * Standard input is mapped into memory via mmap(), then the high-level API * is invoked with three callbacks: input, output, and error. The output * callback converts MAD's high-resolution PCM samples to 16 bits, then * writes them to standard output in little-endian, stereo-interleaved * format. */ static int decode(mp3_file *mp3fp); int main(int argc, char *argv[]) { long flen, fsta, fend; int dlen; mp3_file *mp3fp; if (argc != 2) return 1; mp3fp = (mp3_file *)malloc(sizeof(mp3_file)); if((mp3fp->fp = fopen(argv[1], "r")) == NULL) { printf("can't open source file.\n"); return 2; } fsta = ftell(mp3fp->fp); fseek(mp3fp->fp, 0, SEEK_END); fend = ftell(mp3fp->fp); flen = fend - fsta; if(flen fp, 0, SEEK_SET); fread(mp3fp->fbuf, 1, BUFSIZE, mp3fp->fp); mp3fp->fbsize = BUFSIZE; mp3fp->fpos = BUFSIZE; mp3fp->flen = flen; set_dsp(); decode(mp3fp); close(soundfd); fclose(mp3fp->fp); return 0; } /* * This is the input callback. The purpose of this callback is to (re)fill * the stream buffer which is to be decoded. In this example, an entire file * has been mapped into memory, so we just call mad_stream_buffer() with the * address and length of the mapping. When this callback is called a second * time, we are finished decoding. */ static enum mad_flow input(void *data, struct mad_stream *stream) { mp3_file *mp3fp; int ret_code; int unproc_data_size; /*the unprocessed data's size*/ int _size; mp3fp = (mp3_file *)data; if(mp3fp->fpos flen) { unproc_data_size = stream->bufend - stream->next_frame; memcpy(mp3fp->fbuf, mp3fp->fbuf+mp3fp->fbsize-unproc_data_size, unproc_data_size); _size = BUFSIZE - unproc_data_size; if(mp3fp->fpos + _size > mp3fp->flen) { _size = mp3fp->flen - mp3fp->fpos; } fread(mp3fp->fbuf+unproc_data_size, 1, _size, mp3fp->fp); mp3fp->fbsize = unproc_data_size + _size; mp3fp->fpos += _size; /*Hand off the buffer to the mp3 input stream*/ mad_stream_buffer(stream, mp3fp->fbuf, mp3fp->fbsize); ret_code = MAD_FLOW_CONTINUE; } else { ret_code = MAD_FLOW_STOP; } return ret_code; } /* * The following utility routine performs simple rounding, clipping, and * scaling of MAD's high-resolution samples down to 16 bits. It does not * perform any dithering or noise shaping, which would be recommended to * obtain any exceptional audio quality. It is therefore not recommended to * use this routine if high-quality output is desired. */ static inline signed int scale(mad_fixed_t sample) { /* round */ sample += (1L <= MAD_F_ONE) sample = MAD_F_ONE - 1; else if (sample > (MAD_F_FRACBITS + 1 - 16); } /* * This is the output callback function. It is called after each frame of * MPEG audio data has been completely decoded. The purpose of this callback * is to output (or play) the decoded PCM audio. */ static enum mad_flow output(void *data, struct mad_header const *header, struct mad_pcm *pcm) { unsigned int nchannels, nsamples; unsigned int rate; mad_fixed_t const *left_ch, *right_ch; /* pcm->samplerate contains the sampling frequency */ rate= pcm->samplerate; nchannels = pcm->channels; nsamples = pcm->length; left_ch = pcm->samples[0]; right_ch = pcm->samples[1]; /* update the sample rate of dsp*/ if(rate != prerate) { ioctl(soundfd, SNDCTL_DSP_SPEED, &rate); prerate = rate; } while (nsamples--) { signed int sample; /* output sample(s) in 16-bit signed little-endian PCM */ sample = scale(*left_ch++); writedsp((sample >> 0) & 0xff); writedsp((sample >> 8) & 0xff); if (nchannels == 2) { sample = scale(*right_ch++); writedsp((sample >> 0) & 0xff); writedsp((sample >> 8) & 0xff); } } return MAD_FLOW_CONTINUE; } /* * This is the error callback function. It is called whenever a decoding * error occurs. The error is indicated by stream->error; the list of * possible MAD_ERROR_* errors can be found in the mad.h (or stream.h) * header file. */ static enum mad_flow error(void *data, struct mad_stream *stream, struct mad_frame *frame) { mp3_file *mp3fp = data; fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %u\n", stream->error, mad_stream_errorstr(stream), stream->this_frame - mp3fp->fbuf); /* return MAD_FLOW_BREAK here to stop decoding (and propagate an error) */ return MAD_FLOW_CONTINUE; } /* * This is the function called by main() above to perform all the decoding. * It instantiates a decoder object and configures it with the input, * output, and error callback functions above. A single call to * mad_decoder_run() continues until a callback function returns * MAD_FLOW_STOP (to stop decoding) or MAD_FLOW_BREAK (to stop decoding and * signal an error). */ static int decode(mp3_file *mp3fp) { struct mad_decoder decoder; int result; /* configure input, output, and error functions */ mad_decoder_init(&decoder, mp3fp, input, 0 /* header */, 0 /* filter */, output, error, 0 /* message */); /* start decoding */ result = mad_decoder_run(&decoder, MAD_DECODER_MODE_SYNC); /* release the decoder */ mad_decoder_finish(&decoder); return result; }分享到:
㈦ vs 编译dll出错,求助!
多谢,我编译过去了,但是编译的libmad.dll在使用的时候出问题了。。有错误