?
Solved

Building ANSI-C code with MVC++ 4.0

Posted on 1997-01-20
1
Medium Priority
?
321 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 300 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

764 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