build libevent

## Instructions for building Tor with MinGW (http://www.mingw.org/) ## Stage One: Download and Install MinGW. --------------------------------------- Download mingw: http://prdownloads.sf.net/mingw/MinGW-5.0.3.exe?download Download msys: http://prdownloads.sf.net/mingw/MSYS-1.0.10.exe?download Download the mingw developer tool kit: http://prdownloads.sf.net/mingw/msysDTK-1.0.1.exe?download Install mingw, msys and mingw-dtk. Create a directory called "tor-mingw". Stage Two: Download, extract, compile openssl ---------------------------------------------- Download openssl: http://www.openssl.org/source/openssl-0.9.8d.tar.gz Extract openssl: Copy the openssl tarball into the "tor-mingw" directory. Type "cd tor-mingw/" Type "tar zxf openssl-0.9.8d.tar.gz" Make openssl libraries: Type "cd tor-mingw/openssl-0.9.8d/" Type "./Configure mingw" Edit Makefile and remove the "test:" and "tests:" sections. Type "rm -rf ./test" Type "cd crypto/" Type "find ./ -name "*.h" -exec cp {} ../include/openssl/ /;" Type "cd ../ssl/" Type "find ./ -name "*.h" -exec cp {} ../include/openssl/ /; Type "cd .." Type "cp *.h include/openssl/" # The next steps can take up to 30 minutes to complete. Type "make" Type "make install" Alternatively: Download the pre-compiled openssl for win32. Install and proceed. Stage Three: Download, extract, compile zlib --------------------------------------------- Download zlib source: http://www.zlib.net/zlib-1.2.3.tar.gz Extract zlib: Copy the zlib tarball into the "tor-mingw" directory Type "cd tor-mingw/" Type "tar zxf zlib-1.2.3.tar.gz" CHOICE: Make zlib.a: Type "cd tor-mingw/zlib-1.2.3/" Type "./configure" Type "make" Type "make install" OR Make zlib1.dll: Type "cd tor-mingw/zlib-1.2.3/" Type "./configure" Type "make -f win32/Makefile.gcc" Done. Stage Four: Download, extract, and patch libevent-1.1b. ------------------------------------------------------ Download libevent-1.1b: http://www.monkey.org/~provos/libevent/ Copy the libevent tarball into the "tor-mingw" directory. Type "cd tor-mingw" Extract libevent: Type "tar zxf libevent-1.1b.tar.gz" Download the libevent-1.1b-mingw.diff from http://cvs.seul.org/viewcvs/viewcvs.cgi/tor/trunk/Win32Build/mingw/libevent-1.1b-mingw.diff?rev=8456&root=tor&view=log Copy the libevent-1.1b diff into the libevent-1.1b directory. Type "patch -p0 < libevent-1.1b-mingw.diff" Type "aclocal && autoheader && automake && autoconf". There may be WARNING messages. There will be no output if all runs successfuly. Type "./configure --enable-static --disable-shared" Type "make" Type "make install" Stage Five: Build Tor ---------------------- Download the current Tor alpha release from http://tor.eff.org/download.html. Copy the Tor tarball into the "tor-mingw" directory. Extract Tor: Type "tar zxf latest-tor-alpha.tar.gz" cd tor- Type "./configure --enable-static --disable-shared" Type "make" You now have a tor.exe in src/or/. This is Tor. You now have a tor_resolve.exe in src/tools/.
### 如何安装 Libevent 的指南 #### 准备工作 在开始安装之前,需要确认系统已经具备必要的开发环境和依赖项。例如,在 Linux 系统中通常需要安装 `gcc` 编译器、`make` 构建工具以及 OpenSSL 开发库(如 `libssl-dev`)。这些可以通过包管理器完成安装[^1]。 对于 Debian/Ubuntu 用户: ```bash sudo apt-get update && sudo apt-get install build-essential libssl-dev ``` 对于 CentOS/RHEL 用户: ```bash sudo yum groupinstall "Development Tools" && sudo yum install openssl-devel ``` #### 获取 Libevent 源码 可以从官方 GitHub 仓库获取最新版本的 Libevent 源码[^2]: ```bash git clone https://github.com/libevent/libevent.git cd libevent ``` 如果不想使用 Git,也可以下载压缩包并解压: ```bash wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz tar -xvzf libevent-2.1.12-stable.tar.gz cd libevent-2.1.12-stable ``` #### 配置与构建 进入源码目录后,运行以下命令来配置编译选项。注意,这里可以指定自定义安装路径或者启用特定的功能[^1][^3]。 ```bash ./configure --prefix=/usr/local/libevent ``` 此命令会检测系统中的依赖关系,并生成适合当前平台的 Makefile 文件。完成后继续执行以下步骤: #### 编译与安装 ```bash make sudo make install ``` 此时,Libevent 就会被成功安装到 `/usr/local/libevent` 路径下。如果有特殊需求,则可以在上面提到的 `--prefix` 参数里调整目标位置。 #### 验证安装结果 为了验证 Libevent 是否正确安装,可尝试查看动态链接库是否存在: ```bash ls -l /usr/local/libevent/lib/ ``` 另外还可以利用 grep 查找共享对象文件名是否匹配预期名称[^3]: ```bash ls -al /usr/lib | grep libevent ``` --- ### 注意事项 虽然默认情况下 Libevent 运行在一个单独线程内,但是通过创建多个实例 (struct event_base),能够实现多线程支持[^3]。因此开发者应根据实际应用场景决定采用何种模式部署服务端程序逻辑。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值