Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difficulty getting C package installed

Status
Not open for further replies.

jones172

Programmer
Jul 20, 2002
5
US
Dear Users,

I am tryig to write a program in C (not C++) for a Windows PC. I know the language well, but I am having trouble getting the installation right.
This is Borland C/C++ 5.5. To compile a C program, you activate a DOS window, right? There is a folder into which you type control commands. I call this "Borland." What should this folder contain, beside:

(1) A copy of the compiler, BCC32.exe?
(2) Bit strings which tell the electronics where to find the library. This seems to be fouled up.
(3) Bit strings which tell the electronics where to find the linker. There seem to be two .cfg files involved, but I can't understand what is suppose to go into them.

What is the optimality of buying a C compiler and the documentation in the same shrink wrap, so as to minimuze the likelihood of compatibility isssues?

A related question: Should this work?

---------------------------------------------------------------------

#include <stdio>

{

printf (&quot;Hello, world!\n&quot;);

return;

}

-------------------------------------------------------------------------

Especially, one author said to use return 0

The main folder &quot;Borland&quot; contains a .cfg file with:

-I&quot;c:\Borland\Bcc55\include&quot; -L&quot;c:\Borland\Bcc55\lib&quot;

The error message was &quot;Unable to open include file &quot;stdio.h&quot;

TIA

Tom Jones

DrJones@alum.MIT.edu
 
About that code. I don't know if borland's compiler does any magic to make that work, but normally that would most definately not work. This however would:

#include <stdio.h>

int main()
{
printf(&quot;Hello, world!\n&quot;);
return 0;
}

Or this:

#include <stdio.h>

void main()
{
printf(&quot;Hello, world!\n&quot;);
return;
}

Reasons; first of all you must declare a function called &quot;main&quot;, this is the function that will be called when you run the program after you have compiled it and everything.

You define a function by first of all giving a return type, that the function will return. The most oftenly used for the main-function is int, meaning integer. The &quot;return 0&quot;-statement says that you should end executing your function and return the value given (0 in this case) to whatever called the function (in this case, most probably to DOS). The second example I gave has the return type of &quot;void&quot;, which pretty much means &quot;nothing&quot;, therefore you cannot giva a return value after the &quot;return&quot; since you have expressly said that nothing will be returned. If you say that a function returns void you actually don't have to write a &quot;return;&quot; at the end of the function, it will be implicitly done then you reach the end of the function.

A function in C returning void is pretty much the equivalent of procedures in pascal and such languages.

Any questions or uncertainties about this, don't hesitate to ask =)
 
Dear abbeman:

The top line and the bottom line is that I am completely in over my head when it comes to installing and running Borland C 5.5. It is unclear whether or not I want this package at all, as opposed to an IDE. I have been stuck on dead center, literally for WEEKS. I think I can get the source program right, but installing Borland software is completely beyond my skill set. In fact, I have long since forgotten how to use DOS, which has its own rules about default directories, etc.

Okay, here's the source code:

---------------------------------------------------------------------

#include <stdio.h>

void main ()
{ printf (&quot;Hello World\n&quot;);
return ;
}

------------------------------------------------------------------------

The source code is named helloworld.C.

The parent folder is named Borland. Here is the setup:

Borland
|
|
------------------------------------------------------------
helloworld.c bcc32.exe XXXXXXXXXX


I have tried and tried and TRIED to get the d--- thing to run, but I get various error messages. It will in fact generate an object file. I have put two .cfg files in the Borland folder. Could you explain, in simple terms, how to set up the folder used to compile and run a program? Or maybe I want something else entirely, perhaps an IDE. Or maybe I could call up Borland and ask.

TIA,

Tom Jones

DrJones@alum.MIT.edu
 
Ok. I'm sorry to say that I have no experience what so ever with Borland's compiler since the Turbo C++. And that one had an IDE so I never used any command line programs. And unfortunately I can't try to install it either, since I run Linux exclusively.

The only thing I can tell you is that under linux I would do this:
gcc helloworld.c
to get the program compiled. This would produce a file called a.out and it would require no other files except for the helloworld.c in the directory.

However, it wouldn't surprise me one bit if the Borland compiler is more into cfg-files and stuff.

Hope you get it sorted out =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top