Groups > Borland > Borland C plus plus builder command line tools > Re: ILINK32 options for simple hello world console program




ILINK32 options for simple hello world console program

ILINK32 options for simple hello world console program
Tue, 6 Mar 2007 08:18:07 -0500
Hello,

I have BCB 6 Prof.  My son is working through an online C++ course and I'm 
trying to set up BCC32 and ILINK32 so that he can compile and run the sample 
console programs, and am having a tough time getting the options (especially 
linker options) to make it work.

The first program is very simple, and compiles fine:

#include <iostream.h>
void main()
{
   cout << "Hello World";
}


When I link it, one of the following things happen: (1) unresolved external 
__turboFloat, (2) unresolved external WinMain, or (3) it creates an EXE that 
crashes and wants to tell Microsoft about it.

Ok, I give up.  What are the parameters to give BCC32 and ILINK32 necessary 
to say hello to the old DOS console?

Thanks!
-- 
Richard M. Ulrich
Ulrich Associates, Inc.

Post Reply
Re: ILINK32 options for simple hello world console program
Tue, 6 Mar 2007 09:04:43 -0500
>
> *cough*splutter*
>
> Please let me know which online course this is, so that I can warn
> people against it. The above is *not* valid C++. If they're giving it as
> an example of the language, then I'd strongly distrust anything else
> they taught. [snip]

"OOP Using C++ Series",
http://www.e-learningcenter.com/c_programming.htm

I'm not sure why you say the code is wrong ... to me, it just looks like 
"old style" which is supposed to be supported, since there are
mountains of 
legacy code out there still using that style.

>
> What happens with an actual C++ program?
>
>  #include <iostream>
>  int main()
>  {
>    std::cout << "Hello World";
>  }
>

Very puzzling.

I made the above changes (just two), and  BCC32 compiled AND linked it with 
no fuss.

Ok, so what is going on, I asked.  I changed  <iostream> back to 
<iostream.h> and it still worked.  I then changed std::cout back to cout
and 
... it still worked! I reverted back to the version I KNOW did not work 
before, and it works.  Something peculiar is going on.

R


Post Reply
Re: ILINK32 options for simple hello world console program
Tue, 6 Mar 2007 09:38:32 -0500
>
> For a course that supposedly teaches one how to do the right thing to
> have two egregious errors in such a short example is worrying.

I'd guess what is going on is that this course was developed 15 years ago, 
and they have never updated it.   Yes, worrying, because all sorts of other 
things might be out of date.

Thanks for your help!

R 

Post Reply
Re: ILINK32 options for simple hello world console program
Tue, 6 Mar 2007 10:29:59 -0500
It is not a course but you might get something from this site.  It deals 
with beginning to use the command line compiler and tools and shows a hello 
world example.
  http://www.mulroy.org/howto.htm

Items specific to your situation:
- The compiler and linker are able to create an executable (EXE),
   a dynamic linked library (DLL) and some other items.  Each can
   be created to be dynamic linked or static linked.  You must tell
   the tools what it is that you wish to create.
- If the command line option -c (or /c) is used then the compiler
  will stop after compilation.  If that option is omitted then it will
  call the linker itself.
- To create a command line program give the option -WC to the
  compiler.  For dynamic linked either of the combination -WR -WC
  or a single -WCR is used.

Assuming that your source file is hello.cpp then command lines
used might be:

Console mode, static linked, compiler calls linker
    bcc32 -WC hello
Console mode, static linked, you call linker
    bcc32 -c -WC hello
    ilink32 /Tpe/ap/x/c/Gn c0x32 hello,hello,,import32 cw32
Console mode, dynamic linked, compiler calls linker
    bcc32 -WCR hello
Console mode, dynamic linked, you call linker
    bcc32 -c -WCR hello
    ilink32 /Tpe/ap/x/c/Gn c0x32 hello,hello,,import32 cw32i

Mr Bellingham's comments about correctly following the language are valid 
although I think at your level first getting something to work may be the 
more important issue.  Strict language compliance is an easier goal to 
accept once one has achieved some results.

.  Ed

> Richard M. Ulrich wrote in message
> news:45ed69de$1@newsgroups.borland.com...
>
> I have BCB 6 Prof.  My son is working through an online C++ course and I'm

> trying to set up BCC32 and ILINK32 so that he can compile and run the 
> sample console programs, and am having a tough time getting the options 
> (especially linker options) to make it work.
>
> The first program is very simple, and compiles fine:
>
> #include <iostream.h>
> void main()
> {
>   cout << "Hello World";
> }
>
>
> When I link it, one of the following things happen: (1) unresolved 
> external __turboFloat, (2) unresolved external WinMain, or (3) it creates 
> an EXE that crashes and wants to tell Microsoft about it.
>
> Ok, I give up.  What are the parameters to give BCC32 and ILINK32 
> necessary to say hello to the old DOS console?

Post Reply
Re: ILINK32 options for simple hello world console program
Tue, 06 Mar 2007 13:27:16 +000
"Richard M. Ulrich" <RichardU@UlrichAssociates.com> wrote:

>                     My son is working through an online C++ course and I'm

>trying to set up BCC32 and ILINK32 so that he can compile and run the sample

>console programs, and am having a tough time getting the options (especially

>linker options) to make it work.
>
>The first program is very simple, and compiles fine:
>
>#include <iostream.h>
>void main()
>{
>   cout << "Hello World";
>}

*cough*splutter*

Please let me know which online course this is, so that I can warn
people against it. The above is *not* valid C++. If they're giving it as
an example of the language, then I'd strongly distrust anything else
they taught.

I have BCB5, not BCB6, so I'm afraid I can't really help you with your
actual problem, but it's possibly worth mentioning that <iostream.h>
isn't a standard C++ header (unlike <iostream>), so there may be
problems due to that.

What happens with an actual C++ program?

  #include <iostream>
  int main()
  {
    std::cout << "Hello World";
  }

Does that still cause problems?

Alan Bellingham
-- 
10th Anniversary ACCU Conference: 11-14 April 2007 - Oxford, UK
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact