1. 程式人生 > >不得不再聊linux中的strings命令【轉】

不得不再聊linux中的strings命令【轉】

在軟體開發中, 我們經常需要修改程式碼, 並生成靜態庫、動態庫或者可執行檔案, 有時候, 工程太大, 那怎樣確定自己改動的程式碼正確編譯到庫中去了呢? 用strings命令吧!  為了簡便起見, 我們僅僅以可執行檔案為例:

#include <iostream>
using namespace std;
 
int main()
{
	cout << "hello world" << endl;
	return 0;
}
[[email protected] test]$ g++ test.cpp 
[[email protected] test]$ strings a.out | grep main
__libc_start_main
[
[email protected]
test]$ strings a.out | grep hello hello world [[email protected] test]$

 可見,test.cpp檔案是編譯進了a.out檔案的。 在實際開發中, 我們經常需要用strings命令進行確認和驗證, 確保萬無一失。 有些時候, 你的修改並沒有錯, 但實際並沒有編譯到庫中, 因此不能生效, 納悶良久, 誤導人很長時間的。         我每天幾乎都要用strings命令, 所以慢慢就愛上了strings.

       為了便於瞭解更多關於strings的內容, 我附上之前文章的地址:http://blog.csdn.net/stpeace/article/details/46641069