How to run a program written for an old compiler?

I am looking for a hybrid tree implementation (not important) and find the "old" here .

The author said that they tried this code on the SUN Sparc platform (running Solaris 2.6 ) and with the gcc-2.8.1 compiler. And my gcc environment is version 4.4.3 ( Ubuntu 10.10 ).

The problem is this: I run "make" with the makefile that it provides, but it gives me a lot of error messages as follows:

g++ -c Node.C g++ -c DataNode.C In file included from DataNode.h:18, from DataNode.C:17: Query.h:9:20: error: vector.h: No such file or directory Query.h:10:19: error: stack.h: No such file or directory Query.h:13:22: error: function.h: No such file or directory Query.h:14:22: error: iostream.h: No such file or directory DataNode.C:283:8: warning: extra tokens at end of #endif directive In file included from DataNode.h:18, from DataNode.C:17: Query.h:29: warning: 'typedef' was ignored in this declaration Query.h:44: warning: 'typedef' was ignored in this declaration Query.h:86: error: expected initializer before '<' token Query.h:118: error: ISO C++ forbids declaration of 'PQ' with no type Query.h:118: error: expected ';' before '*' token Query.h:122: error: ISO C++ forbids declaration of 'PQ' with no type Query.h:122: error: expected ';' before '*' token Query.h:126: error: ISO C++ forbids declaration of 'PQ' with no type Query.h:126: error: expected ';' before '*' token Query.h:135: error: expected initializer before '<' token DataNode.C: In member function 'void DataNode::DisconnectBranch(int)': DataNode.C:80: error: 'memmove' was not declared in this scope make: *** [DataNode.o] Error 1 

I know that I need to change the access code to accept the morden compiler, for example change vector.h to vector . But I find it just endless.

So my question is: is there any convienent method to run this program, regardless of whether it automatically converts this code to a "modern style" or using a stand-alone "old style" compiler?

Any suggestions?

=== Update: ===

Thanks to everyone, I installed gcc2.8.1 to another directory using --prefix=/usr/local/gcc-2.8.1 and changed the "makefile" to use this old version of gcc ( /usr/local/gcc-2.8.1/bin/gcc ). But when I run "make", it still gives me errors in the absence of headers:

 /usr/local/gcc-2.8.1/bin/gcc -c DataNode.C In file included from DataNode.h:18, from DataNode.C:17: Query.h:9: vector.h: No such file or directory Query.h:10: stack.h: No such file or directory Query.h:11: deque: No such file or directory Query.h:12: algorithm: No such file or directory Query.h:13: function.h: No such file or directory Query.h:14: iostream.h: No such file or directory make: *** [DataNode.o] Error 1 

Then I tried to find these chapters in / usr / local / gcc -2.8.1 using find /usr/local/gcc-2.8.1 -name "*vector*" but got nothing.

So where are these heads for the old version of gcc?

+7
source share
6 answers

You can do vertor.h yourself, which includes a vector. This way you can fix incompatibilities non-invasively.

Edit:

You may also need to add using namespace std; in the header file. This is usually a bad idea, but this is one of the situations when I will do it anyway.

Once you earn it, I recommend rewriting it to use the new header files and namespaces.

+7
source

Debian Lenny (oldstable) has gcc 3.4. This may have better backward compatibility. Try making compatibility headers for the rest of the problems and include them through the optional -I directory, for example. a vector.h header file that includes vector .

Do yourself a favor and try not to touch the old code. It's easy to break legacy code in unforeseen ways.

+3
source

You can try running a program on QEMU that supports Solaris 2.6 . The only problem may be finding the installation disk / image. In addition, there are people who sell old Solaris boxes on eBay for cheap, you might be able to grab them.

GCC provides downloads for very old versions, you can get a better chance if you try an older version of the compiler.

0
source

gcc has the -fpermissive : try it and see if at least some errors go away. Also: try creating a single header file that will include all the necessary headers using directives. For example, make stdinc.h containing:

 #include <vector> #include <iostream> #include <stack> ... using std::vector; using std::fstream; ... 

Replace all references to legacy C ++ header files with one inclusion of stdinc.h . Old C ++ did not have namespaces, so even if you replace individual directives only using namespace std; collisions are unlikely.

0
source

If the only thing is

 #include <vector.h> 

to

 #include <vector> using namespace std; 

Why not try sed?

grep for all includes to see if there are others besides C ++ headers. If no luck.

Another complication is that there is old code that uses non-standard data access through iterators. I saw this in the Doom map editor for Linux. Then you may need to do manual work.

0
source

To get started, try removing the ".h" from the system header files mentioned in the error message. This will probably give you other errors, but just try to fix them one by one.

-2
source

All Articles