Category: Unix

  • Linux中如何創建靜態庫和動態庫

    靜態庫在程序編譯時會被連接到目標代碼中,程序運行時將不再需要該靜態庫。   動態庫在程序編譯時並不會被連接到目標代碼中,而是在程序運行是才被載入,因此在程序運行時還需要動態庫存在。   程序1: hello.h   #ifndef HELLO_H   #define HELLO_H   void hello(const char *name);   #endif //HELLO_H   程序2: hello.c   #include <stdio.h>   void hello(const char *name)   {   printf(“Hello %s!\n”, name);   }   程序3: main.c   #include “hello.h”   int main()   {   hello(“everyone”);   return 0;   }   無論動態庫還是靜態庫都需要用到.o文件來生成,先編譯生成.o文件。   # gcc -c hello.c   1:創建靜態庫   靜態庫文件名的命名規範是以lib為前綴,緊接著跟靜態庫名,擴展名為.a。例如:我們將創建的靜態庫名為myhello,則靜態庫文件名就是libmyhello.a。   # ar cr libmyhello.a hello.o   使用靜態庫:只需要在妳的源程序中加入包含妳所需要使用到的函數的聲明(即包含頭文件),然後在gcc生成目標文件時候指明靜態庫就OK了(除非妳包含的頭文件在/usr/include,庫文件在標準庫/usr/lib,/lib下,否則妳得顯示指明他們的路徑)   # gcc -o hello…

  • 輕松解決Linux系統grub錯誤

    Linux在現在已經很強大了,導致Linux系統越來越受到電腦用戶的歡迎,於是很多人開始學習Linux時,學習時妳可能會遇到Linux系統grub常見錯誤問題,這裏將介紹Linux系統grub常見錯誤問題的解決方法,讓大家了解壹下。   1:Filenamemustbeeitheranabsolutefilenameorblocklist   解釋:1號錯誤表示文件名格式錯誤。在GRUB中要麽是以絕對路徑給出文件   例子:   grub>kernelvmlinuzroot=label=/   Error1:Filenamemustbeeitheranabsolutepathnameorblocklist   grub>   2:Badfileordirectorytype   解釋:2號錯誤表示命令期望的是壹個普通文件,但相應文件名的對象是壹個符號鏈接、目錄、FIFO   例子:   grub>kernel/testdirroot=LABEL=/   Error2:Badfileordirectorytype   grub>   3:Badorcorruptdatawhiledecompressingfile   解釋:3號錯誤表示解壓文件時發生錯誤。可能是因為這個文件被損壞了   4:Badorincompatibleheaderincompressedfile   解釋:4號錯誤表示壓縮文件的頭部格式不被兼容或者錯誤   5:Partitiontableinvalidorcorrupt   解釋:5號錯誤表示分區表無效或者被破壞。這是壹個不好的預兆   6:Mismatchedorcorruptversionofstage1/stage2   解釋:6號錯誤表示install命令發現stage1和stage2的頒布號不被兼容   7:Loadingbelow1MBisnotsupported   解釋:Thiserrorisreturnedifthelowestaddressinakernelisbelow   the1MBboundary.TheLinuxzImageformatisaspecialcaseand   canbehandledsinceithasafixedloadingaddressandmaximumsize   8:Kernelmustbeloadedbeforebooting   解釋:8號錯誤表示執行boot命令之前沒有先執行kernel命令   9:Unknownbootfailure   解釋:9號錯誤表示未知的引導錯誤   10:UnsupportedMultibootfeaturesrequested   解釋:10號錯誤表示請求Multibootheader所要求功能不被GRUB所支持。   11:Unrecognizeddevicestring   解釋:11號錯誤表示無法識別的設備字符串。   例子:   grub>roothd0   Error11:Unrecognizeddevicestring   grub>   12:Invaliddevicerequested   解釋:12號錯誤表示請求的設備無效   例子:   grub>root(hd2)   Error21:Selecteddiskdoesnotexist   grub>kernel/grub/grub.confroot=LABEL=/   Error12:Invaliddevicerequested   grub>   13:Invalidorunsupportedexecutableformat   解釋:13號錯誤表示無效或者無法識別的可執行格式   例子:   grub>kernel/grub/grub.confroot=LABEL=/   Error13:Invalidorunsupportedexecutableformat   grub>   14:Filesystemcompatibilityerror,cannotreadwholefile   解釋:14號錯誤表示文件系統兼容性錯誤,無法讀取整個文件   15:Filenotfound   解釋:請求的文件無法找到…

  • 疑难解答-windows快速批處理更換IP

    做了兩個批處理用於快速切換IP和網關。   @echo off   rem eth //eth 為網卡名稱,可在網絡連接中查詢,如”本地鏈接”   set eth=”無線網絡連接”   rem ip //ip 為妳想更改的IP   set ip=192.168.1.8   rem gw //gw 為網關地址   set gw=192.168.1.1   rem netmasks //netmasks 為子網掩碼   set netmasks=255.255.255.0   echo 正在將本機IP更改到: %ip%   rem   if %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% > nul   if not %gw%==none netsh interface ip set address %eth% static…