Solved

Building ANSI-C code with MVC++ 4.0

Posted on 1997-01-20
1
312 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now