crtmpserver源码编译(Unix)静态编译及部分问题解决


本文编译在 Unix环境 中完成

步骤:
1进入目录
#cd crtmpserver/builders/cmake
2生成make文件(cmake .(有个点))
#cmake .
3编译
#make
当达到100%编译成功(若失败请参考下文,重新编译时,若配置文件有改动请先清理./cleanup.sh
4运行

#./crtmpserver/crtmpserver crtmpserver/crtmpserver.lua

只要相关端口不被占用应该成功,被占用也会有提示

静态编译(20141108补充)
在CMakeList.txt开始位置加入下面一句即可

SET(ENV{COMPILE_STATIC} "1")


打包安装:
进入到目录crtmpserver/builders/cmake
运行命令:

cmake . -DCMAKE_BUILD_TYPE=Release -DCRTMPSERVER_INSTALL_PREFIX=<install-dir  (例如 /usr/local/crtmpserver)
make make install

 
在 /usr/local/crtmpserver中可以看到整理好的文件
crtmpserver在sbin文件夹中
crtmpserver.lua在etc文件夹中
 
存在package.sh文件的话,运行可得到配置文件的压缩包,
没有没关系,就在工程crtmpserver的主目录下,有configs,media等目录,自己打包下,
实在不会就用官方编译好的(*.so跟crtmpserver替换成自己的就行)
 
按照官方编译好的进行整理
建议把libdl.so, libssl.so, libcrypto.so都放进去 ,避免在其它机子上不能运行。
 

部分问题解决方式
1 cmake
缺少cmake命令,请到官网进行下载
  cmake官网: http://www.cmake.org/
直接下最新的就行
安装步骤:

#tar xvf cmake-2.x.x.tar.gz 
#cd cmake-2.x.x/
#./bootstrap
#make
#make install

安装完毕,cmake命令可以直接使用

2 openssl crypto
不存在openssl肯定要装
cmake .能通过,但make时碰到 crypto.cpp错误,那就是openssl版本过低,需要安装新的
  openssl官网: http://www.openssl.org/
  openssl下载地址: http://www.openssl.org/source/
 建议下openssl-0.9.8x.tar.gz版,1.0.0可能有的编译不过
安装步骤:
#tar -xzf openssl-xxx.tar.gz
#./config --prefix=/usr/local/openssl shared zlib-dynamic enable-camellia
修改配置,使之生成.so文件,/usr/local/openssl是自定义安装位置,可自行修改,位置要记住,之后要修改文件
#./config -t 
#make depend
#make install
安装完毕,还需修改文件
位置:crtmpserver/builders/cmake/cmake_find_modules/
修改文件:Find_openssl.cmake

FIND_PATH(OPENSSL_INCLUDE_PATH 
 NAMES
  openssl/ssl.
  PATHS 
 /usr/local/openssl/include 
 ${TOOLCHAIN_HEADER_PATH}
....................................................
FIND_LIBRARY(OPENSSL_LIBRARY_PATH  
NAMES 
 ssl 
 PATHS
 /usr/local/openssl/lib
 ${TOOLCHAIN_LIBRARY_PATH}
.....................................................
FIND_LIBRARY(CRYPTO_LIBRARY_PATH 
 NAMES 
 crypto 
 PATHS 
 /usr/local/openssl /lib
 ${TOOLCHAIN_LIBRARY_PATH}
................................................

添加红色文字部分,具体位置看你编译时安装的位置而定,cmake .后应该可以看到( 要先./cleanup.sh)路径
..................................................................
-- OPENSSL_INCLUDE_PATH: /usr/local/openssl/include
-- OPENSSL_LIBRARY_PATH: /usr/local/openssl/lib/libssl.so
-- CRYPTO_LIBRARY_PATH: /usr/local/openssl/lib/libcrypto.so
.....................................................................
应该能够看到以上三行信息,确保路径是所安装的路径
3 iotimer.cpp sys/timerfd.h
缺少这两个文件所带来的错误,应该是Unix内核版本过低,不支持所致,也无需换Unix系统
位置: crtmpserver/sources/common/include/platform/linux
修改文件:linuxplatform.h
//#define HAS_EPOLL_TIMERS
将其注释掉即可(老内核不支持,不使用该方式即可)
重新编译要从头开始, 要先./cleanup.sh
C++ RTMP Server Instructions how to compile and use C++ RTMP Server (a.k.a crtmpserver) Requirements: * GCC and other C++ tools * SVN * libdl, libssl, libcrypto (make sure you have the "devel" packages of libdl, ssl and crypto installed prior to compiling) In order to get the source code, issue the following command: svn co --username anonymous https://svn.rtmpd.com/crtmpserver/trunk crtmpserver When it asks for password, hit Enter key Compile the package. Do the following steps: cd crtmpserver/builders/cmake cmake . (this step will create all the Makefile's that are required. If some package is missing, the cmake will complain) make The compilation procedure should be finished within few minutes. After you compiled the package, it's time to test it. Run the following command: ./crtmpserver/crtmpserver crtmpserver/crtmpserver.lua If everything goes well, you'll get on your console a table with IP's, ports, protocols, and application names If you see this table, then crtmpserver is working. Lets test it the server. Follow these simple steps: * Download a simple FLV or MP4 file. You can dowload a sample file from here: http://www.mediacollege.com/adobe/flash/video/tutorial/example-flv.html * Place the file you downloaded into the crtmpserver/media folder * Download an FLV player. For this example, we'll use JW Player. Get it here: http://www.longtailvideo.com/players/jw-flv-player * Extract the JW Player to a directory which is accessible through your web server * Go to the extracted directory and create an HTML file which will include the player and play the file. Here's an example: <html> <body> <script type='text/javascript' src='swfobject.js'></script> <div id='mediaspace'>This text will be replaced</div> <script type='text/javascript'> var so = new SWFObject('player.swf','mpl','640','360','9'); so.addParam('allowfullscreen','true'); so.addParam('allowscriptaccess','always'); so.addParam('wmode','opaque'); so.addVariable('file','file-download'); so.addVariable('streamer','rtmp://127.0.0.1/flvplayback/'); so.write('mediaspace'); </script> </body> </html> * Change the 127.0.0.1 to either the IP of your crtmpserver or simply use a hostname of your machine * Replace file-download with the actual filename of your sample you download. Remeber to omit the .flv if it's an FLV file * Open a web browser and point it to to the web server IP/Hostname and the directory you installed the player (example: http://127.0.0.1/player) * You should see a player. Click the play button and the video should be played. If you see the video, then everything works well. Installing crtmpserver: * Go to the directory crtmpserver/cmake * Run the following command: cmake -DCRTMPSERVER_INSTALL_PREFIX=<path> (for example /usr/local/crtmpserver) * After previous command done start build project with command: make * After build comlete run command: make install * After install you has installed crtmpserver in <path>(in our case /usr/local/crtmpserver) * Now you can start crtmpserver with command: sudo <path>/sbin/crtmpserver --uid=<UID> <path>/etc/crtmpserver.lua in our case: sudo /usr/local/crtmpserver/sbin/crtmpserver --uid=<UID> /usr/local/crtmpserver/etc/crtmpserver.lua Also look into builders/packing directory. There are several OS specific builders. * in directory "debian" builder for Debian, also can be used for Ubuntu and other distributions based on debian * in directory "freebsd" builder(port) for FreeBSD crtmpserver settings * All crtmpserver settings are located in a detailed file calle: crtmpserver.lua
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值