最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

net-snmp靜態(tài)編譯鏈接的獲取程序及生成執(zhí)行程序詳解

 更新時(shí)間:2023年08月02日 09:33:03   作者:龔正陽  
這篇文章主要介紹了net-snmp靜態(tài)編譯鏈接的獲取程序及生成執(zhí)行程序詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

引言

由于在某些場景需要使用靜態(tài)鏈接的snmpwalk或者其他程序,為了方便執(zhí)行文件的分發(fā),適配多版本系統(tǒng),所以需要自己編譯net-snmp

實(shí)驗(yàn)操作系統(tǒng)Ubuntu22 amd64

獲取程序

git clone方式

$ git clone https://github.com/net-snmp/net-snmp.git

或者也可以依據(jù)tag下載源碼包

生成Makefile

net-snmp項(xiàng)目根路徑下面有一個(gè)configure文件,可以用于生成Makefile,命令執(zhí)行過程中會(huì)彈出一些輸入確認(rèn),直接回車確認(rèn)即可

$ ./configure --prefix=/tmp/snmp --disable-embedded-perl --without-perl-modules --disable-ucd-snmp-compatibility --disable-scripts

--prefix參數(shù)指定文件安裝目錄到/tmp/snmp

需要禁用perl相關(guān)模塊以及一些腳本,否則可能會(huì)遇到錯(cuò)誤如下

relocation R_X86_64_PC32 against symbol `netsnmp_ds_handle_config' can not be used when making a shared object; recompile with -fPIC

生成執(zhí)行程序

如果此時(shí)項(xiàng)目根目錄下面生成一個(gè)Makefile,則表示configure命令成功

執(zhí)行程序的源碼和生成的二進(jìn)制都在apps/目錄下

$ make LDFLAGS="-static"

校驗(yàn)生成的二進(jìn)制執(zhí)行文件,發(fā)現(xiàn)不是靜態(tài)鏈接的

$ ldd apps/snmpwalk
        linux-vdso.so.1 (0x00007ffed71c1000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007ff639800000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff639400000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff639d7e000)

靜態(tài)編譯snmpwalk

發(fā)現(xiàn)在make snmpwalk執(zhí)行的時(shí)候會(huì)產(chǎn)生兩條執(zhí)行命令,第一條是 gcc包含-static參數(shù),但是第二條沒包含

$ cd apps
$ rm snmpwalk
$ make snmpwalk
/bin/bash ../libtool  --mode=link gcc  -static -g -O2 -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -g -O2 -Ulinux -Dlinux=linux  -Wall -Wextra -Wstrict-prototypes -Wwrite-strings -Wcast-qual -Wimplicit-fallthrough -Wlogical-op -Wundef -Wno-format-truncation -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter  -o snmpwalk snmpwalk.lo ../snmplib/libnetsnmp.la   
libtool: link: gcc -g -O2 -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -g -O2 -Ulinux -Dlinux=linux -Wall -Wextra -Wstrict-prototypes -Wwrite-strings -Wcast-qual -Wimplicit-fallthrough -Wlogical-op -Wundef -Wno-format-truncation -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -o snmpwalk .libs/snmpwalk.o  ../snmplib/.libs/libnetsnmp.a -lm -lssl -lcrypto

所以需要執(zhí)行命令如下,把make snmpwalk的輸出的第二條命令粘貼下來,手動(dòng)在gcc后面加上-static參數(shù)

$ rm snmpwalk
$ gcc -static -g -O2 -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -g -O2 -Ulinux -Dlinux=linux -Wall -Wextra -Wstrict-prototypes -Wwrite-strings -Wcast-qual -Wimplicit-fallthrough -Wlogical-op -Wundef -Wno-format-truncation -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -o snmpwalk .libs/snmpwalk.o  ../snmplib/.libs/libnetsnmp.a -lm -lssl -lcrypto 
# 執(zhí)行的時(shí)候會(huì)產(chǎn)生告警信息如下,這是正常的
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libcrypto.a(libcrypto-lib-dso_dlfcn.o): in function `dlfcn_globallookup':
(.text+0x17): 警告: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ../snmplib/.libs/libnetsnmp.a(system.o): in function `netsnmp_str_to_gid':
/home/gong/rust-work/github/net-snmp/snmplib/system.c:1492: 警告: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the bc version used for linking
/usr/bin/ld: /home/gong/rust-work/github/net-snmp/snmplib/system.c:1494: 警告: Using 'endgrent' in statically linked applications requires at runtime the shared librar from the glibc version used for linking
/usr/bin/ld: ../snmplib/.libs/libnetsnmp.a(system.o): in function `netsnmp_str_to_uid':
/home/gong/rust-work/github/net-snmp/snmplib/system.c:1459: 警告: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the bc version used for linking
/usr/bin/ld: /home/gong/rust-work/github/net-snmp/snmplib/system.c:1461: 警告: Using 'endpwent' in statically linked applications requires at runtime the shared librar from the glibc version used for linking
/usr/bin/ld: ../snmplib/.libs/libnetsnmp.a(system.o): in function `netsnmp_getaddrinfo':
/home/gong/rust-work/github/net-snmp/snmplib/system.c:884: 警告: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ../snmplib/.libs/libnetsnmp.a(system.o): in function `netsnmp_gethostbyaddr':
/home/gong/rust-work/github/net-snmp/snmplib/system.c:1050: 警告: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries frome glibc version used for linking
/usr/bin/ld: ../snmplib/.libs/libnetsnmp.a(system.o): in function `netsnmp_gethostbyname':
/home/gong/rust-work/github/net-snmp/snmplib/system.c:980: 警告: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from  glibc version used for linking

檢查snmpwalk鏈接

$ ldd snmpwalk

 不是動(dòng)態(tài)可執(zhí)行文件

之后也可以把生成的snmpwalk復(fù)制到另外一臺(tái)古老的linux上運(yùn)行校驗(yàn),如果機(jī)器上有docker, 可以執(zhí)行命令docker run -it alpine sh,把snmpwalk復(fù)制到容器內(nèi)部執(zhí)行

以上就是net-snmp靜態(tài)編譯鏈接的獲取程序及生成執(zhí)行程序詳解的詳細(xì)內(nèi)容,更多關(guān)于net-snmp靜態(tài)編譯鏈接的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • .yml是什么文件(編寫規(guī)則)

    .yml是什么文件(編寫規(guī)則)

    YAML (YAML Aint Markup Language) 是一種標(biāo)記語言,一種專門用來寫配置文件的語言, 可用于如: Java,C/C++, Ruby, Python, Perl, C#, PHP等,本文對.yml文件詳細(xì)講解,包括編寫規(guī)則和yml優(yōu)點(diǎn),感興趣的朋友跟隨小編一起看看吧
    2024-01-01
  • Git單分支與多分支的協(xié)作流程

    Git單分支與多分支的協(xié)作流程

    本文介紹了Git的基本用法,包括配置用戶名和郵箱、clone和it兩種初始化方式,接著詳細(xì)講解了兩種分支協(xié)作場景的操作流程和注意事項(xiàng);最后總結(jié)了常見問題及解決方法,需要的朋友可以參考下
    2026-04-04
  • Git沖突處理指南之如何高效解決代碼沖突問題

    Git沖突處理指南之如何高效解決代碼沖突問題

    我們在日常使用Git的過程中經(jīng)常會(huì)發(fā)生一些意外情況,如果處理不當(dāng),則可能會(huì)出現(xiàn)代碼丟失的假象,這篇文章主要給大家介紹了關(guān)于Git沖突處理指南之如何高效解決代碼沖突問題的相關(guān)資料,需要的朋友可以參考下
    2024-08-08
  • 使用HTTP_X_FORWARDED_FOR獲取客戶端IP的嚴(yán)重后果

    使用HTTP_X_FORWARDED_FOR獲取客戶端IP的嚴(yán)重后果

    我的建議是不要再使用上面的方法去獲取客戶端IP.即是不要再理會(huì)代理情況.
    2009-11-11
  • 關(guān)于ANSI轉(zhuǎn)義序列解讀

    關(guān)于ANSI轉(zhuǎn)義序列解讀

    這篇文章主要介紹了關(guān)于ANSI轉(zhuǎn)義序列的使用,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • Git中忽略文件機(jī)制的.gitignore與.git/info/exclude兩種方式詳解

    Git中忽略文件機(jī)制的.gitignore與.git/info/exclude兩種方式詳解

    Git提供了兩種忽略文件的方式,是.gitignore和.git/info/exclude,兩者在作用范圍和共享性上有本質(zhì)區(qū)別,下面小編就和大家詳細(xì)介紹一下具體實(shí)現(xiàn)吧
    2026-01-01
  • 自定義?Github?Action?庫實(shí)戰(zhàn)詳解

    自定義?Github?Action?庫實(shí)戰(zhàn)詳解

    這篇文章主要為大家介紹了自定義?Github?Action?庫實(shí)戰(zhàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • ChatGPT如何寫好Prompt編程示例詳解

    ChatGPT如何寫好Prompt編程示例詳解

    這篇文章主要為大家介紹了ChatGPT如何寫好Prompt編程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • IDEA/WebStorm切換分支方法(超簡單)

    IDEA/WebStorm切換分支方法(超簡單)

    這篇文章主要介紹了IDEA/WebStorm切換分支方法的相關(guān)資料,包括使用命令行、IDEA和WebStorm的右鍵菜單、狀態(tài)欄以及Git面板,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-11-11
  • 基于 Serverless +企業(yè)微信打造 nCoV 疫情監(jiān)控小助手

    基于 Serverless +企業(yè)微信打造 nCoV 疫情監(jiān)控小助手

    這篇文章主要介紹了基于 Serverless +企業(yè)微信打造 nCoV 疫情監(jiān)控小助手,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-02-02

最新評論

徐闻县| 衢州市| 神农架林区| 小金县| 河源市| 右玉县| 高尔夫| 竹山县| 兴国县| 湖口县| 开化县| 三亚市| 淳化县| 佛学| 扎囊县| 略阳县| 鄄城县| 汶上县| 和硕县| 高要市| 黄骅市| 玉溪市| 汤原县| 庄浪县| 永仁县| 金昌市| 左贡县| 江城| 雅江县| 宁波市| 九龙县| 乌拉特前旗| 东乌珠穆沁旗| 当涂县| 和静县| 东乌珠穆沁旗| 九寨沟县| 延川县| 石林| 綦江县| 镇宁|