我正嘗試在Solaris 11上使用Solaris Studio 12.x構建一個簡單的Hello World程序。如果我從兩個不同的文件夾編譯相同的文件,目標文件,如diff命令或cmp命令所示。Solaris Studio在目標文件中添加當前目錄信息
對這兩個目標文件(od -x)進行了十六進制轉儲,並對它們進行了比較,並使用可將十六進制轉換爲ASCII的在線工具,發現差別正在發生,因爲目標文件包含當前編譯目錄被啓動。
問題是如何告訴編譯器不要在目標文件中包含當前目錄的信息。嘗試了幾個優化選項 - 沒有用於解決這個問題。
這裏是我使用的代碼和命令:
bash-4.1$ cat a.cpp
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
bash-4.1$ ls
a.cpp temp1 temp2
bash-4.1$ cd temp1
bash-4.1$ /opt/SunProd/studio12u3/solarisstudio12.3//bin/CC ../a.cpp
bash-4.1$ cd ../temp2
bash-4.1$ /opt/SunProd/studio12u3/solarisstudio12.3//bin/CC ../a.cpp
bash-4.1$ cd ..
bash-4.1$ diff temp1/a.out temp2/a.out
Binary files temp1/a.out and temp2/a.out differ
bash-4.1$ cmp temp1/a.out temp2/a.out
temp1/a.out temp2/a.out differ: char 5968, line 24
bash-4.1$ od -x temp1/a.out > temp1/a.hex
bash-4.1$ od -x temp2/a.out > temp2/a.hex
bash-4.1$ diff -c temp1/a.hex temp2/a.hex
... shows hex diff (two sets) ...