openssl交叉編譯
⑴ 小白求助,如何在ubuntu的QT creator下完成交叉編譯
你需要先安裝嵌入式版本的Qt
以下是我編譯Qt時的命令:樓主看著自行改
./configure -prefix /opt/QtEmbedded-4.7.3 -release -shared -fast -pch -no-qt3support -qt-sql-sqlite -no-libtiff -no-libmng -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -no-openssl -nomake examples -nomake demos -nomake tools -optimized-qmake -no-phonon -no-nis -no-opengl -no-cups -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-xkb -no-sm -no-xinerama -no-xshape -no-separate-debug-info -xplatform qws/linux-arm-g++ -embedded arm -depths 16 -no-qvfb -qt-gfx-linuxfb -no-gfx-qvfb -no-kbd-qvfb -no-mouse-qvfb -confirm-license -qt-mouse-tslib
然後把生成的Qt的qmake所在的目錄加入的Qt creater中,工具鏈就選你上面的那個arm-linux-g++
然後新建項目的時候就可以選擇 Embedded什麼來著
這樣就搞定了!
⑵ 一個C語言工程在linux下用gcc編譯可以通過,但用arm-linux-gcc交叉編譯會報錯。
這個很正常,交叉編譯的頭文件和標準的不一樣,定義的時候缺少一些宏豎滑或者函數,根據情況稍微修改一般可以的。除非是操作系統不一樣飢纖蠢否則一般都可以很快改正。
舉一個不容易改正的例子,MingW是一種Windows下的GCC移植版本,但是它沒有fork,所以如果程序中存在fork就會報錯,但是這個錯誤很難爛陪修正,因為Windows裡面沒有fork函數。
⑶ OpenSSL的編譯和使用
個人博客地址: https://blog.yookingh.cn
該文章地址: https://blog.yookingh.cn/dev/201215-openssl.html
從NDK r19開滑知始,由於gcc兼容clang的編譯方式有問題,該版本乎高已經移除了相關gcc文件,所以用老方法交叉編譯Openssl的時候,會提示找不到gcc文件。
參考: https://blog.csdn.net/zoujin6649
build-android-single.sh 腳本文件及注釋如下歲讓尺
執行腳本
修改腳本為 循環編譯 ,編譯所有需要的文件
build-android-all.sh 腳本文件內容如下
執行腳本方法同上,如為第一次執行(即沒有Makefile文件),仍需要執行 ./config 循環編譯無需執行 make clean
參考: https://blog.csdn.net/iamadk
Python 腳本內容
創建編譯執行腳本
執行編譯腳本同r15,第一次需要執行 ./config 生成Makefile,第二次或以上需要清除make記錄即 make clean ,接下來依舊是創建 循環編譯 腳本
⑷ 如何將openssl aes源碼移植到嵌入式
移植步驟如下:
1、首先將openssl 源碼download下來;
2、在你的嵌入式開發環境中,交叉編譯openssl源碼,生成庫文件;
3、在你的嵌入式程序中,添加對交叉編譯後的openssl庫文件的支持,並在socket通信中調用ssl相關的函數。
⑸ 交叉編譯zlib出錯
$ export CC=mipsel-linux-gcc
$ ./configure --prefix=/opt --shared
$ make CC=mipsel-linux-gcc
$ make install
ps:此處的環境CC=mipsel-linux-gcc 記得換回來!
⑹ 在unbuntu下使用openssl 寫一個加密的C程序,編譯提示找不到頭文件openssl/*.h
哥門 <openssl/aes.h> 里 的openssl只是文件夾名字而已,
在linux下面 /usr/local/include/ /usr/include/ 這兩個路徑是默認引用的。
所以你沒加 -I 也是可以編譯的 。
當交叉編譯時,那就完全不一樣了,必須配置好所有路徑。
⑺ 如何在windows平台下編譯比特幣bitcoin客戶端
很多朋友都知道如何在linux平台如何編譯比特幣程序,但是,到了windows平台,
就會感覺到無從下手. 其實, 比特幣程序是跨平台的.
你要編譯windows版的比特幣程序,基本上有兩種方法,一種是在linux平台
(推薦ubuntu 13.10)通過交叉編譯的方法來編譯.另外一種,就是直接在windows平台編譯.
我想,你既然要在windows平台使用,我就詳細介紹一下如何在windwows平台編譯比特幣程序.
我的平台:windows7
第一步:安裝變編譯環境QT和MINGW,msys
1、msys是一個在windows平台模擬shell的程序。
下載安裝程序之後,通過安裝管理程序,按安裝以下內容:
From MinGW installation manager -> All packages -> MSYS
選中以下安裝包
msys-base-bin
msys-autoconf-bin
msys-automake-bin
msys-libtool-bin
點 apply changes開始安裝。他會自動下載安裝好。
需要注意的是,確保不要安裝msys-gcc和msys-w32api ,因為這兩個包和我們的編譯系統發生沖突。
很多人出現一些莫名其妙的問題,就是因為這兩個包。
2、安裝 MinGW-builds
下載並解壓縮 i686-4.8.2-release-posix-dwarf-rt_v3-rev3.7z 到C盤根目錄 C:\
注意我的目錄結構。你盡量和我一樣。
3、設置PATH環境變數,將C:\mingw32\bin;添加到第一個。
4、在命令行模式下輸入 gc -v 會得到以下內容
c:\gcc -v
Using built-in specs.
COLLECT_GCC=c:\mingw32\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.8.2/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-4.8.2/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32 --with-gxx-include-dir=/mingw32/i686-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw482/prerequisites/i686-w64-mingw32-static --with-cloog=/c/mingw482/prerequisites/i686-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='i686-posix-dwarf-rev3, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32/opt/include -I/c/mingw482/prerequisites/i686-zlib-static/include -I/c/mingw482/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32/opt/include -I/c/mingw482/prerequisites/i686-zlib-static/include -I/c/mingw482/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw482/i686-482-posix-dwarf-rt_v3-rev3/mingw32/opt/lib -L/c/mingw482/prerequisites/i686-zlib-static/lib -L/c/mingw482/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
Thread model: posix
gcc version 4.8.2 (i686-posix-dwarf-rev3, Built by MinGW-W64 project)
至此,你的開發環境已經搭建好了,很簡單吧
第二部分:下載bitcoin引用的外部庫
我們把它們全部放在 C:\deps目錄下
2.1 安裝OpenSSL
進入啟動 MinGw shell 比如目錄:(C:\MinGW\msys\1.0\msys.bat)運行這個msys.bat,就會啟動一個shell環境,提示符是$
輸入命令
cd /c/deps/
tar xvfz openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
Configure no-shared no-dso mingw
make
等待幾分鍾後,就把openssl編譯好了。
2.2 下載Berkeley DB
我們推薦使用 4.8版本
同樣在msys shell環境下輸入以下命令
cd /c/deps/
tar xvfz db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
../dist/configure --enable-mingw --enable-cxx --disable-shared --disable-replication
make
等待編譯
2.3 安裝Boost
msys命令:
cd C:\deps\boost_1_55_0\
bootstrap.bat mingw
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc variant=release link=static threading=multi runtime-link=static stage
2.4 安裝Miniupnpc
cd C:\deps\miniupnpc
mingw32-make -f Makefile.mingw init upnpc-static
msys shell命令
cd /c/deps/protobuf-2.5.0
configure --disable-shared
make
2.6 qrencode:
命令
cd /c/deps/libpng-1.6.10
configure --disable-shared
make
LIBS="../libpng-1.6.10/.libs/libpng16.a ../../mingw32/i686-w64-mingw32/lib/libz.a" \
png_CFLAGS="-I../libpng-1.6.10" \
png_LIBS="-L../libpng-1.6.10/.libs" \
configure --enable-static --disable-shared --without-tools
make
2.7 安裝 Qt 5 庫
下載和解壓縮
在 windows命令行輸入:
set INCLUDE=C:\deps\libpng-1.6.10;C:\deps\openssl-1.0.1g\include
set LIB=C:\deps\libpng-1.6.10\.libs;C:\deps\openssl-1.0.1g
cd C:\Qt\5.2.1
configure.bat -release -opensource -confirm-license -static -make libs -no-sql-sqlite -no-opengl -system-zlib -qt-pcre -no-icu -no-gif -system-libpng -no-libjpeg -no-freetype -no-angle -no-vcproj -openssl-linked -no-dbus -no-audio-backend -no-wmf-backend -no-qml-debug
mingw32-make
set PATH=%PATH%;C:\Qt\5.2.1\bin
cd C:\Qt\qttools-opensource-src-5.2.1
qmake qttools.pro
mingw32-make
3. 下載Bitcoin 0.9.1
在msys shell下輸入以下命令行:
cp /c/deps/libpng-1.6.10/.libs/libpng16.a /c/deps/libpng-1.6.10/.libs/libpng.a
cd /c/bitcoin-0.9.1
./autogen.sh
CPPFLAGS="-I/c/deps/boost_1_55_0 \
-I/c/deps/db-4.8.30.NC/build_unix \
-I/c/deps/openssl-1.0.1g/include \
-I/c/deps \
-I/c/deps/protobuf-2.5.0/src \
-I/c/deps/libpng-1.6.10 \
-I/c/deps/qrencode-3.4.3" \
LDFLAGS="-L/c/deps/boost_1_55_0/stage/lib \
-L/c/deps/db-4.8.30.NC/build_unix \
-L/c/deps/openssl-1.0.1g \
-L/c/deps/miniupnpc \
-L/c/deps/protobuf-2.5.0/src/.libs \
-L/c/deps/libpng-1.6.10/.libs \
-L/c/deps/qrencode-3.4.3/.libs" \
./configure \
--disable-upnp-default \
--disable-tests \
--with-qt-incdir=/c/Qt/5.2.1/include \
--with-qt-libdir=/c/Qt/5.2.1/lib \
--with-qt-bindir=/c/Qt/5.2.1/bin \
--with-qt-plugindir=/c/Qt/5.2.1/plugins \
--with-boost-system=mgw48-mt-s-1_55 \
--with-boost-filesystem=mgw48-mt-s-1_55 \
--with-boost-program-options=mgw48-mt-s-1_55 \
--with-boost-thread=mgw48-mt-s-1_55 \
--with-boost-chrono=mgw48-mt-s-1_55 \
--with-protoc-bindir=/c/deps/protobuf-2.5.0/src
make
strip src/bitcoin-cli.exe
strip src/bitcoind.exe
strip src/qt/bitcoin-qt.exe
這樣,你就得到了變異好的 bitcoin-cli.exe和bitcoind.exe ,bitcoin-qt.exe(windows QT圖形界面的錢包軟體)
⑻ jdk nginx. redis 在arm和x86要分別編譯
一、注意openssl和pcre只需要把源碼解壓縮,不需要單獨交叉編譯!
開始的時候不知道,傻傻的把這兩個庫弄半天把它們編譯過去了。誰知道nginx的--with-pcre和--with-openssl選項,指定的是這兩個庫源代碼的路徑,並非安裝路徑!nginx的編譯系統只會從/usr、/usr/local等少數幾個目錄查找是否有預編譯的pcre、zlib、openssl等庫。對於交叉編譯,直接把交叉編譯後的pcre等安裝在/usr、/usr/local顯然不合適,因此需要使用--with-pcre和--with-openssl指定源代碼的位置
二、交叉編譯nginx
在x64 linux上面編譯非常簡單的nginx,沒想到在交叉編譯的時候巨多坑。下面一個configure是編譯成功的配置
進入/usr/local/src目錄,創建nginx文件夾。入剛創建的nginx目錄,下載nginx的tar包,解壓,進入解壓生成的目錄,進行配置(後面有補充,建議通讀一遍)編譯安裝查找安裝路徑,在執行make編譯時,可以添加要編譯的參數,已安裝完成,比如我現在要新增 http_stub_status_mole 模塊參數,那麼我只要把該參數添加進去然後重新編譯即可,需要注意的是原先編譯過的參數也要加進來。
進入nginx的安裝目錄,因為我安裝的時候沒有添加任何參數,所以這里我只需要執行
我這里只需要這一個模塊,如果你安裝的nginx還使用其他的模塊,記得在上面的編譯命令中加上。
另外,這里只能 make 千萬別 make install,否則就覆蓋安裝了。
make完成後,在源碼目錄下會有一個objs目錄,objs目錄下就多了個nginx,這個就是新版本的程序了;
然後將objs目錄下的nginx替換之前已經安裝過的nginx(建議將舊的nginx程序做下備份)
,