Solved

Building ANSI-C code with MVC++ 4.0

Posted on 1997-01-20
1
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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