2012-01-06 130 views
1

我正在做我的碩士論文,我在配置交叉編譯器時遇到問題。我讀過很多文章,常見問題解答,教程等,但我仍然認爲我錯過了一些東西,可能非常愚蠢和基礎,但沒有這些,我不能清楚地看到一切,而且我也不會使所有工作...所以請隨時解釋我的一切。讓我們來解決這個問題。安裝mips交叉編譯器的問題

我正在使用SoClib設計具有許多MIPS和許多RAM的NoC,並且我想在每個RAM中加載不同的應用程序,以使每個MIPS只從一個RAM讀取。我設法用非常簡單的應用程序來做到這一點(比如hello word with interrupts ...),所以現在我試圖實現一個JPEG解碼器,以更強烈的方式使用MIPS。問題是我使用的交叉編譯器找不到基本的stdio函數,所以無法編譯mips的應用程序。所以基本上我沒有設法安裝一個完整的交叉編譯器。

1)Let's開始與SoClib安裝交叉編譯: 這裏有導向從來就跟着來安裝它:http://www.soclib.fr/trac/dev/wiki/CrossCompiler 現在從什麼從來就讀這不是一個完整的交叉編譯器。我只安裝了第一階段的gcc,可以爲mips生成elf代碼,但不能使用任何C函數。用那個,我應該編譯一個C庫來創建一個新的交叉編譯器。所以這是正常的,它不工作,雖然這並不回答這個問題:爲什麼「Hello world」工作,如果它使用printf幷包括stdio.h?答案應該是我已經看到SoClib的頭文件stdio.h中實現了很少的功能(printf在那裏),所以我不能在該編譯器中使用標準的C庫。 2)因爲這個,我決定安裝一個完整的交叉編譯器,並且我已經閱讀了很多指南,我只會發布我在練習中使用的兩個: http://www.cse.iitb.ac.in/grc/gcc-workshop-11/downloads/slides/gccw11-config-build.pdf(從第108頁開始)交叉編譯問題) 它使用EGLIBC。唯一的區別是我用作目標「米勒精靈」。如果我理解正確,這種方法需要3階段交叉編譯器,因爲eglibc不能用第一階段交叉編譯器完全編譯。現在的問題是,我無法用第一階段交叉編譯器安裝eglibc(它在第122頁失敗)。我附上了日誌。我認爲問題開始於它說:「mipsel-elf-gcc:錯誤:無法識別的選項'-V'」和「mipsel-elf-gcc:致命錯誤:沒有輸入文件編譯終止」。似乎我有一些編譯器的問題,並完成一個不支持的平臺......但它應該工作,因爲我已經複製eglibc/ports目錄像指南所說...

3)我試過另一個指南,使用newlib而不是eglibc: http://www(dot)cygwin(dot)com/ml/crossgcc/2005-08/msg00114/l-cross-ltr.pdf 本指南僅創建2階段交叉編譯器。我認爲這是因爲newlib可以用第一階段編譯器完全編譯......我是對的嗎?無論如何,我遇到同樣的問題。我無法編譯newlib,並且出現類似的錯誤(附加日誌)。

所以這是我的問題,在這裏我提出了一些疑問,我試圖解決它。

4)問題可能是目標= mipsel-elf嗎?我從gnu文檔中知道,配置gnu的名字應該是:cpu-manufacturer-os(或者cpu-manufacturer-kernel-os),但我讀過mipsel-elf被接受。小精靈應該是因爲我不想在我的NoC平臺上加載操作系統,這裏有第二個疑問......

5)問題是操作系統的問題嗎?這些指南使用Linux內核頭文件...也許有一個mipsel-elf目標我不應該配置binutils -with-sysroot?但聽起來很奇怪......應該改變什麼?

6)又一個可能是愚蠢的問題。 stdio和一般的C函數,不需要一個操作系統?因爲所有這些問題都讓我對基礎知識產生懷疑......所以我應該能夠用mipsel-elf交叉編譯器運行JPEG解碼C應用程序吧?

每一個考慮,建議和幫助將不勝感激。如果你有一些關於這些論點的文件,請讓我知道,我想學習,並在這個領域變得更加自信。 感謝

eglibc日誌:

configure:2426: $? = 0 
configure:2433: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5 
Using built-in specs. 
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc 
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper 
Target: mipsel-elf 
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror 
Thread model: single 
gcc version 4.6.2 (GCC) 
configure:2437: $? = 0 
configure:2444: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5 
mipsel-elf-gcc: error: unrecognized option '-V' 
mipsel-elf-gcc: fatal error: no input files 
compilation terminated. 
configure:2448: $? = 1 
configure:2452: checking for suffix of object files 
configure:2478: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5 
configure:2482: $? = 0 
configure:2507: result: o 
configure:2511: checking whether we are using the GNU C compiler 
configure:2540: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c conftest.c >&5 
configure:2547: $? = 0 
configure:2564: result: yes 
configure:2573: checking whether /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc accepts -g 
configure:2603: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g conftest.c >&5 
configure:2610: $? = 0 
configure:2711: result: yes 
configure:2728: checking for /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc option to accept ISO C89 
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -c -g -O2 conftest.c >&5 
conftest.c:9:19: fatal error: stdio.h: No such file or directory 
compilation terminated. 
configure:2809: $? = 1 
configure: failed program was: 
| /* confdefs.h. */ 
| #define PACKAGE_NAME "GNU C Library" 
| #define PACKAGE_TARNAME "glibc" 
| #define PACKAGE_VERSION "(see version.h)" 
| #define PACKAGE_STRING "GNU C Library (see version.h)" 
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/" 
| /* end confdefs.h. */ 
| #include <stdarg.h> 
| #include <stdio.h> 
| #include <sys/types.h> 
| #include <sys/stat.h> 
| /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ 
| struct buf { int x; }; 
| FILE * (*rcsopen) (struct buf *, struct stat *, int); 
| static char *e (p, i) 
|  char **p; 
|  int i; 
| { 
| return p[i]; 
| } 
| static char *f (char * (*g) (char **, int), char **p, ...) 
| { 
| char *s; 
| va_list v; 
| va_start (v,p); 
| s = g (p, va_arg (v,int)); 
| va_end (v); 
| return s; 
| } 
| 
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has 
| function prototypes and stuff, but not '\xHH' hex character constants. 
| These don't provoke an error unfortunately, instead are silently treated 
| as 'x'. The following induces an error, until -std is added to get 
| proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an 
| array size at least. It's necessary to write '\x00'==0 to get something 
| that's true only with -std. */ 
| int osf4_cc_array ['\x00' == 0 ? 1 : -1]; 
| 
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters 
| inside strings and character constants. */ 
| #define FOO(x) 'x' 
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; 
| 
| int test (int i, double x); 
| struct s1 {int (*f) (int a);}; 
| struct s2 {int (*f) (double a);}; 
| int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); 
| int argc; 
| char **argv; 
| int 
| main() 
| { 
| return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; 
| ; 
| return 0; 
| } 
configure:2802: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qlanglvl=extc89 -c -g -O2 conftest.c >&5 
mipsel-elf-gcc: error: unrecognized 

選項 '-qlanglvl = extc89選項' 配置:2809:$? = 1

NEWLIB登錄

configure:4049: $? = 0 
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -v >&5 
Using built-in specs. 
COLLECT_GCC=/home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc 
COLLECT_LTO_WRAPPER=/home/bertone/programmazione/crosscompiler/mips/install/libexec/gcc/mipsel-elf/4.6.2/lto-wrapper 
Target: mipsel-elf 
Configured with: ../../../../../Scaricati/src/gcc-4.6.2/configure --target=mipsel-elf --prefix=/home/bertone/programmazione/crosscompiler/mips/install --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c --disable-werror 
Thread model: single 
gcc version 4.6.2 (GCC) 
configure:4049: $? = 0 
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -V >&5 
mipsel-elf-gcc: error: unrecognized option '-V' 
mipsel-elf-gcc: fatal error: no input files 
compilation terminated. 
configure:4049: $? = 1 
configure:4038: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc -qversion >&5 
mipsel-elf-gcc: error: unrecognized option '-qversion' 
mipsel-elf-gcc: fatal error: no input files 
compilation terminated. 
configure:4049: $? = 1 
configure:4069: checking for C compiler default output file name 
configure:4091: /home/bertone/programmazione/crosscompiler/mips/install/bin/mipsel-elf-gcc conftest.c >&5 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crti.o: No such file or directory 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtbegin.o: No such file or directory 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find -lgcc 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtend.o: No such file or directory 
/home/bertone/programmazione/crosscompiler/mips/install/lib/gcc/mipsel-elf/4.6.2/../../../../mipsel-elf/bin/ld: cannot find crtn.o: No such file or directory 
collect2: ld returned 1 exit status 
configure:4095: $? = 1 
configure:4132: result: 
configure: failed program was: 
| /* confdefs.h */ 
| #define PACKAGE_NAME "" 
| #define PACKAGE_TARNAME "" 
| #define PACKAGE_VERSION "" 
| #define PACKAGE_STRING "" 
| #define PACKAGE_BUGREPORT "" 
| #define PACKAGE_URL "" 
| /* end confdefs.h. */ 
| 
| int 
| main() 
| { 
| 
| ; 
| return 0; 
| } 
configure:4138: error: in `/home/bertone/programmazione/crosscompiler/mips/build/newlib': 
configure:4142: error: C compiler cannot create executables 

回答

0

首先,關閉,您是否需要這些stdio功能?

您可以替換這些stdio函數嗎?例如,你真的真的需要一個printf(其中一個更痛苦的),或者你可能願意用別的東西替換它們,也許string_display()和hex_display()函數可能很容易實現和庫和系統獨立。

這些文件I/O功能?我似乎記得一個流行的開源jpeg解碼器想爲你做文件I/O。實現一個fopen()有多難?(只返回任何有效的),一個fread,它跟蹤一個包含在二進制文件中的常量數據的指針,並且執行mem copy和fwrite deal會跟蹤數組中的指針,並執行mem副本。

我已經嵌入jpeg解碼器,mp3等,使系統調用,都通過使用newlib(),這使得它更容易一點,但是現在非常痛苦的建立一個交叉編譯器,並且還取代了系統調用具有不同的功能或通過實現這些功能的模擬。

如果您使用免費的codesourcery精簡版(現在稱爲codebench或其他東西,因爲它是導師圖形,而不是codesourcery了),並用模擬的替換系統調用,你不必再與編譯器混亂了。

我有一些非常簡單的mips代碼,但也有一些關於構建我所說的GNU交叉編譯器的說明(如果你沒有用於系統調用,C庫調用,gcc庫調用,自己實施一切)。

https://github.com/dwelch67/pic32_samples

它是不是從什麼我建立一個完整的交叉編譯一個遠伸。 Gcc/gnu不太穩定,您可以從任何版本交叉編譯任何版本並使其工作,同樣,任何使用任何版本的主機上的任何版本的任何目標的交叉編譯器都不穩定。有時一個目標版本的binutils + gcc + newlib恰好工作。例如,在這段時間/歷史這個工作,無論是在Linux上,並與windows上的mingw。

http://www.dwelch.com/ipod/gccarm.txt

,但除非你使用虛擬機(VMware的,等等),並在其上安裝一個老的Linux與舊足夠建造系統,你將無法建立以上。

不久前,也許還是這個工作的現代化系統。它適用於手臂,但也可能適用於mips。

http://www.cowlark.com/2009-07-04-building-gcc/

我不認爲我有任何貼有沒有系統調用或模擬的系統調用在那裏我可以把它們發佈的地方使用的MP3和zlib和JPEG庫的代碼。如果你想使用zlib作爲性能測試什麼的,一個時間壓縮或解壓縮或兩者mallocs很容易實現的東西像zlib的,不是一個通用的東西,而是一個控制的測試環境,在數據和數據輸出。這同樣適用於其他受控環境JPEG編碼或解碼,MP3編碼或解碼(他們是有損,所以你不能比較的輸入到輸出一定要驗證系統產生正確的結果,但對已知的良好系統相比,校驗或CRC很容易/結果)。

如果您檢查newlib,我空出並更換後,你可以看到什麼newlib沸騰標準輸入輸出要求下入文件,那麼您需要執行每這些功能。我有一對夫婦至少有Dhrystone的實例非常簡單,只是想一個printf http://www.dwelch.com/ipod/ http://www.dwelch.com/gba/dhry.htm在這裏你可以看到我做了什麼與newlib功能了網站,大多隻是通過返回一個傳遞值來消除它們,並計算出newlib在輸出到stdout時的行爲。

或更換,由此導致一些仍然有效的複用功能的一些標準輸入輸出調用的一個例子。不是說它很漂亮,但你可以玩遊戲。 https://github.com/dwelch67/stm32f4d/blob/master/adventure/

基本上我正在閱讀的是,你已經確定了一個問題,但只追求一條路徑,在編譯器端解決它。當你可以通過創建一個抽象層或填充來解決它,或者完全刪除違規代碼或用較少的令人反感的代碼替換它。如果您查看上述冒險遊戲以及類似時代遊戲帝國等的源代碼,即使是小型的c編譯器和已經移植過多次的其他代碼,您也可以看到他們的確完成了這些,他們解決了這個問題,語言,非系統特定的調用,然後最後一英里是在一個或幾個系統特定的地方實現這些調用。即使您要獲得gcc + newlib或gcc + glibc交叉編譯器,您仍然必須使用自己的代碼將缺省stdio替換爲操作系統層。 (這也是編譯器的一面,也是一個龐大的抽象層,glibc,newlib等等,你仍然需要實現後端)。

0

爲什麼不直接下載免費的預建GCC Codesourcery Lite交叉編譯器,MIPS工具鏈?

6) The stdio and generally C functions, doesn´t need an OS right?

通常,libc的轉化標準輸入輸出調用到系統調用底層的操作系統,所以你需要有標準輸入輸出工作的OS。如果您的JPEG解碼器應用程序沒有調用任何需要操作系統的任何東西,它可以正常工作,但是您需要創建一種方法,以便從NoC中的每個單獨的CPU獲得結果到外部世界。