2009-01-14 95 views
0

我需要一個Windows可執行文件,用於一些代碼,這是1994年爲UNIX編寫的。我試圖從cygwin環境中做到這一點。 C++標準也從這個時間和標準庫中改變了。編譯舊的C++ unix應用程序在Windows中使用

我試圖用-std = - 傳統和-CPP的選擇,但選擇沒有幫助我。我還發現-fno-for-scope和-fno-operator-names減少了錯誤數量。此外,輸入/輸出庫也發生了顯着變化。我也認爲,預定義宏(預處理器)也有可能從那時起改變。

提交人對代碼的註釋:
http://research.microsoft.com/en-us/um/people/hoppe/code.htm

+0

如果您至少描述了您在嘗試編譯此代碼時遇到的錯誤之一,您嘗試糾正錯誤以及結果如何,可能會對我們有所幫助。 – 2009-01-14 06:57:23

回答

1

在庫(庫/ LINPACK和庫/配方)C代碼使用編譯罰款:

gcc -c *.c 

的C++代碼是更成問題。在../include中有頭文件,他們需要-DANSI來生成函數原型。它們在頭文件中未被聲明爲extern "C";它們包含正確的C++源代碼目錄標題:

extern "C" { 
#include "linpack.h" 
} 

所以,編譯A3dStream.C,我得到:

$ g++ -DANSI -I../include -c A3dStream.C 
In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31, 
       from Hh.h:12, 
       from A3dStream.C:4: 
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: 
warning: #warning This file includes at least one deprecated or antiquated header. 
Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ 
standard. Examples include substituting the <X> header for the <X.h> header for 
C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable 
this warning use -Wno-deprecated. 
In file included from A3dStream.C:4: 
Hh.h:15:23: strstream.h: No such file or directory 
In file included from A3dStream.C:4: 
Hh.h:45: error: declaration of C function `void bzero(void*, int)' conflicts with 
/usr/include/string.h:54: error: previous declaration `void bzero(void*, size_t)' here 
Hh.h:46: error: declaration of C function `int gethostname(char*, int)' conflicts with 
/usr/include/sys/unistd.h:206: error: previous declaration `int gethostname(char*, size_t)' here 
Hh.h:98: error: an explicit specialization must be preceded by 'template <>' 
Hh.h:105: error: an explicit specialization must be preceded by 'template <>' 
Hh.h:111: error: an explicit specialization must be preceded by 'template <>' 
Hh.h:221: error: new declaration `void unsetenv(const char*)' 
/usr/include/cygwin/stdlib.h:26: error: ambiguates old declaration `int unsetenv(const char*)' 
In file included from Geometry.h:10, 
       from A3dStream.h:7, 
       from A3dStream.C:5: 
Array.h: In member function `void Array<T>::resize(int)': 
Array.h:40: error: `size' undeclared (first use this function) 
Array.h:40: error: (Each undeclared identifier is reported only once for each function it appears in.) 
Array.h:44: error: `a' undeclared (first use this function) 
Array.h: In member function `void Array<T>::clear()': 
Array.h:51: error: `a' undeclared (first use this function) 
Array.h:51: error: `size' undeclared (first use this function) 
Array.h: In member function `void Array<T>::init(int)': 
Array.h:53: error: `size' undeclared (first use this function) 
Array.h: In member function `void Array<T>::need(int)': 
Array.h:57: error: `size' undeclared (first use this function) 
Array.h: In member function `Array<T>& Array<T>::operator+=(const T&)': 
Array.h:64: error: `a' undeclared (first use this function) 
Array.h: In member function `void Array<T>::squeeze()': 
Array.h:66: error: `size' undeclared (first use this function) 
Array.h: In member function `const T& Array<T>::operator[](int) const': 
Array.h:70: error: `a' undeclared (first use this function) 
Array.h: In member function `T& Array<T>::operator[](int)': 
Array.h:71: error: `a' undeclared (first use this function) 

其他文件產生的錯誤類似的套。

我在Windows XP下的Cygwin上使用GCC 3.4.4。

我不是一個C++大師 - 儘管我公平地分享了軟件考古學 - 但是在我看來,你需要更新代碼來使用C++標準頭文件,因爲缺少strstream.h (所以,名義上,使用<strstream>代替),這意味着你將不得不處理std命名空間等。此代碼將標準預先標記了5年,因此不得不很難將其更新到最新版本。

祝你好運!

0

我能想到的兩種可能性:AT &牛逼同時提供UWIN(可能是不同的夠多了Cygwin來避免同樣的麻煩)和old versions of CFront源(這可能是使用原始編譯器)。

嗯,還有第三種可能性,我認爲這是建議的行動:編輯源代碼,並把它最新的標準。如果您打算對此代碼進行進一步的開發,最好儘早咬住這顆子彈。

0

您仍然可以從GNU網站下載gcc 2.7.0的源代碼。

您可以下載並編譯舊版本的編譯器。

相關問題