Ubuntu編譯gdb ARM除錯環境

2022-03-07 04:48:11 字數 3085 閱讀 9545

參考qt可用的gdb編譯,以及交叉編譯gdbserver,以及配置qtcreator遠端除錯

**編譯指令碼 **如下:

#!/bin/bash

echo -e "\033[32m 正在執行步驟一:檢查python-dev包 \033[0m"

chkpydev=$(dpkg -l | grep python-dev)

if [ "$chkpydev" == "" ]; then

sudo apt-get install python-dev --force-yesfi

echo "#include " > check.c

echo "#include " >> check.c

echo "int main() " >> check.c

gcc -rdynamic -o check check.c -ldl && ./check

checkpy=$?

rm check

rm check.c

echo -e "\033[32m 正在執行步驟二:gdb的configure \033[0m"

case $checkpy in

1)echo "沒有找到libpython2.7.so"

exit

;;2)

./configure cflags="-o3" cxxflags="-o3" --target=arm-none-linux-gnueabi --prefix=/opt/arm-none-linux-gnueabi-gdb/ --with-python

;;3)

./configure cflags="-dpy_unicode_wide -o3" cxxflags="-dpy_unicode_wide -o3" --target=arm-none-linux-gnueabi --prefix=/opt/arm-none-linux-gnueabi-gdb/ --with-python

;;esac

echo -e "\033[32m 正在執行步驟三:編譯和安裝gdb \033[0m"

make -j8

if [ $? -eq 0 ]; then

make install

echo -e "\033[32m gdb已安裝到/opt/arm-none-linux-gnueabi-gdb/目錄下 \033[0m"

else

echo -e "\033[31m gdb編譯失敗 \033[0m"

exitfi

echo -e "\033[32m 正在執行步驟四:gdbserver的confiure \033[0m"

cd gdb/gdbserver

./configure cflags="-o3" cxxflags="-o3" --target=arm-none-linux-gnueabi --prefix=/opt/arm-none-linux-gnueabi-gdb/ --host=arm-none-linux-gnueabi

echo -e "\033[32m 正在執行步驟五:編譯和安裝gdbserver \033[0m"

make -j8

if [ $? -eq 0 ]; then

make install

echo -e "\033[32m gdbserver已安裝到/opt/arm-none-linux-gnueabi-gdb/目錄下 \033[0m"

else

echo -e "\033[31m gdbserver編譯失敗 \033[0m"

exitfi

echo -e "\033[32m 正在執行步驟六:壓縮可執行檔案,將gdb放入交叉編譯工具鏈 \033[0m"

cd /opt/arm-none-linux-gnueabi-gdb/bin/

cp arm-none-linux-gnueabi-gdbserver gdbserver

arm-none-linux-gnueabi-strip gdbserver

echo "arm-none-linux-gnueabi-strip gdbserver"

strip arm-none-linux-gnueabi-gdb arm-none-linux-gnueabi-run

echo "strip arm-none-linux-gnueabi-gdb arm-none-linux-gnueabi-run"

gdb_path=$(which arm-none-linux-gnueabi-gdb)

cross_path=$/..

mv $(which arm-none-linux-gnueabi-gdb) $cross_path/bin/arm-none-linux-gnueabi-gdb.bk

echo "mv $cross_path/bin/arm-none-linux-gnueabi-gdb $cross_path/bin/arm-none-linux-gnueabi-gdb.bk"

cp arm-none-linux-gnueabi-gdb $cross_path/bin

echo "cp arm-none-linux-gnueabi-gdb $cross_path/bin"

mv $(which arm-none-linux-gnueabi-run) $cross_path/bin/arm-none-linux-gnueabi-run.bk

echo "mv $cross_path/bin/arm-none-linux-gnueabi-run $cross_path/bin/arm-none-linux-gnueabi-run.bk"

cp arm-none-linux-gnueabi-run $cross_path/bin

echo "cp arm-none-linux-gnueabi-run $cross_path/bin"

cd ..

cp -rf share $cross_path

echo "cp -rf share $cross_path"

echo -e "\033[32m 已經將新的arm-none-linux-gnueabi-gdb放入交叉編譯工具鏈目錄$cross_path/bin \033[0m"

echo -e "\033[32m 完成 \033[0m"

centos swig 編譯c,python呼叫

swig是個幫助使用c或者c 編寫的軟體能與其它各種高階程式語言進行嵌入聯接的開發工具。swig能應用於各種不同型別的語言包括常用指令碼編譯語言例如perl,php,python,tcl,ruby and php。最新的版本已經開始支援golang了。tar zxvf swig 3.0.6.tar....

ubuntu 編譯核心

第一步 安裝必要的工具 首先要安裝必要的包。包有 libncurses5 dev menuconfig 需要的 和 essential sudo apt get install build essential kernel package 核心打包deb的可以不用裝手動安裝 sudo apt get...

Ubuntu編譯環境

一.安裝基本的編譯環境和一些輔助工具,如文件等。sudo apt get install manpages dev 安裝c c 的man手冊,這樣你就可以隨時的檢視一些你不太了解的函式的原型,具體引數說明等 還可以檢視一些include檔案的具體說明。sudo apt get install bui...