Solved

Building ANSI-C code with MVC++ 4.0

Posted on 1997-01-20
1
318 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

695 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