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在使用的時候出問題了。。有錯誤