Solved

Building ANSI-C code with MVC++ 4.0

Posted on 1997-01-20
1
315 Views
Last Modified: 2012-06-27
I downloaded extensive ANSI-C compatible source code that I need for a simulation I am working on.  The downloaded project contains a number of header files and  makefiles written for gcc.  I would like to be able to build and run this project (presumably in console mode unless it is easier to do it otherwise) on my MSVC++ 4.0 compiler and then make some minor adjustments to the code.  

The problem is I have no idea how to get the project to build on my compiler! I have no experience using makefiles or building external projects.  I need step by step
guidance about how to get the thing
built.  The Microsoft instructions
about this have been worthless.  All help will
be eternally appeciated.




0
Comment
Question by:davis012097
1 Comment
 
LVL 1

Accepted Solution

by:
navigator010897 earned 150 total points
ID: 1162207
You should be able to make a new project in MSVC and then compile the code like you would any other project you make.  

So, you would go to NEW in the file menu,
select Project Workspace
Give you project a new name.
Copy all of the header files and c/c++ files into
 the project directory (to preseve the original  
 files incase of problems)
Start inserting the C/C++ files into the project.
Build the executable.

Here are the things you may need to look for:

The old program was made with intention to be compiled on GCC, this being the case, you have a standard GCC makefile.  You're going to want to either print (easier) or open the file and read the file itself.  Most lines probably describe making '.o' files (ie: search.o), then there is a line that has all of the '.o' files and puts them together to make the executable.  the .o files are object files, basically steps in compilation.  If you had multiple files in MSVC, it would compile to C code to get object files, then link them with the standard libraries to get the actual program

What you are going to need to look for in the makefile is if the code makes a libSOMETHING.a
(ie: libmsql.a), if it does, then it is compiling a library file, and you are going to need to build a library project in MSVC, then include your compiled library in the link options.

Another thing to be aware of:  gcc is mostly on UNIX systems (yes, I know there is a port to DOS), and it may have requirements for UNIX specific libraries.  if it does, find out what the libraries are for and if there are a set in the MSVC world.

You are also going to need to check all of the header files the program needs.  Some headerfiles require libraries that are not automatically linked at compile time.

Final note: as a console application, you should make sure you include:

#include <windows.h>

in the C file that has MAIN.

Good luck!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question