Avatar billede fredand Forsker
07. juni 2004 - 14:16 Der er 15 kommentarer og
2 løsninger

Hello World in C++ With Textpad?

Hello!

I would like to use TextPad with the free compiler from Borland. I have this simple code, but it will not work:
#include <iostream.h>

main()
{
    cout << "Hello World!";
    return 0;
}


I only get this error message:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
c:\fredrik\c++\helloworld.cpp:
Error E2209 c:\fredrik\c++\helloworld.cpp 1: Unable to open include file 'iostream.h'
Error E2451 c:\fredrik\c++\helloworld.cpp 5: Undefined symbol 'cout' in function main()
*** 2 errors in Compile ***

Tool completed with exit code 1


Do I have to install anything else or set some paths?


Best regards
Fredrik
Avatar billede medions Nybegynder
07. juni 2004 - 14:18 #1
Prøv sådan her:

#include <iostream>

using namespace std;

int main ()
{
  cout << "Hello World!" << endl;
  return 0;
}

//>Rune
Avatar billede medions Nybegynder
07. juni 2004 - 14:18 #2
Du mangler at angive et namespace... :)

//>Rune
Avatar billede arne_v Ekspert
07. juni 2004 - 14:21 #3
Besides the changes medions suggested (which makes the code compatible with
th alatest ANSI C++ standard) you probably need to add the correct paths
to the bcc32 and ilink32 config files.

It is described in the readme file if I remember correct.
Avatar billede fredand Forsker
07. juni 2004 - 15:19 #4
Hello Mates!

The problem seems to be the things that arne_v talks about. But I changed the code to medions answer.

And I created the 2 files in C:\Borland\BCC55\:
(bcc32.cfg like)
-I "C:\Borland\BCC55\Include"
-L "C:\Borland\BCC55\Lib"

(ilink32.cfg like)
-L "C:\Borland\BCC55\Lib"


But I still get:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
c:\fredrik\c++\helloworld.cpp:
Error E2209 c:\fredrik\c++\helloworld.cpp 1: Unable to open include file 'iostream'
Error E2282 c:\fredrik\c++\helloworld.cpp 3: Namespace name expected
Error E2451 c:\fredrik\c++\helloworld.cpp 7: Undefined symbol 'cout' in function main()
Error E2451 c:\fredrik\c++\helloworld.cpp 7: Undefined symbol 'endl' in function main()
*** 4 errors in Compile ***

Tool completed with exit code 1

So if any one see any errors that I can correct please let me know.

Best regards
Fredrik
BTW always give svar so I can reward you!
Avatar billede arne_v Ekspert
07. juni 2004 - 15:47 #5
Are the path C:\Borland\BCC55 correct ?
Avatar billede fredand Forsker
07. juni 2004 - 15:54 #6
Hello!

Yes the path is for eg. : C:\Borland\BCC55\ilink32.cfg

I can't understand whats wrong?

Best regards
Fredrik
Avatar billede arne_v Ekspert
07. juni 2004 - 15:56 #7
The two files need to be in

C:\Borland\BCC55\Bin
Avatar billede arne_v Ekspert
07. juni 2004 - 15:57 #8
answer
Avatar billede fredand Forsker
07. juni 2004 - 16:09 #9
OK!

That were a step in the right direction!

But now I got:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Error E2075: Incorrect configuration file option: C:\Borland\BCC55\Include

Tool completed with exit code 1

So if you have any suggestions what to do, please let me know.

Best regards
Fredrik
Avatar billede fredand Forsker
07. juni 2004 - 16:11 #10
Hmm!

What do they mean with this:
2. From the bin directory of your installation:
  a. Add "c:\Borland\Bcc55"
      to the existing path

existing path???

Aha the path-variable perhaps?

/Fredrik
Avatar billede arne_v Ekspert
07. juni 2004 - 16:11 #11
try and remove the space between the capital latter and the double quote
Avatar billede arne_v Ekspert
07. juni 2004 - 16:12 #12
control panel
system
advanced
environment
add c:\Borland\Bcc55 to PATH
Avatar billede arne_v Ekspert
07. juni 2004 - 16:13 #13
I just have a BCBDEF.BAT with:

@echo off
PATH=C:\Borland\bcc55\bin;%PATH%

so before the first compile I just:

BCBDEF
Avatar billede fredand Forsker
07. juni 2004 - 16:14 #14
Doh!

Same problem still. Hmpf!!

So if any one have any suggestion please let me know!

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Error E2075: Incorrect configuration file option: C:\Borland\BCC55\Include

Tool completed with exit code 1

/Fredrik
Avatar billede fredand Forsker
07. juni 2004 - 16:26 #15
Hello!

I removed a space character at each line in the config-files like:
(bcc32.cfg like)
-I"C:\Borland\BCC55\Include"
-L"C:\Borland\BCC55\Lib"

(ilink32.cfg like)
-L"C:\Borland\BCC55\Lib"

But now I get:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
c:\fredrik\c++\helloworld.cpp:
Error E2133: Unable to execute command 'ilink32.exe'

Tool completed with exit code 1

/Fredrik
Avatar billede fredand Forsker
07. juni 2004 - 16:33 #16
Hello!

I solved it!

I had to add this to the path-variable:
C:\Borland\Bcc55\bin
so the system find the *.exe files

Thanks for your help amigos!

/Fredrik
Avatar billede arne_v Ekspert
07. juni 2004 - 16:33 #17
That is because you have not changed the PATH !

Either put C:\Borland\BCC55\Bin in the PATH or use:

C:\Borland\BCC55\Bin\bcc32 -c helloworld.cpp
C:\Borland\BCC55\Bin\ilink32 helloworld.obj
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester