Mail Archives: djgpp/1995/03/24/00:58:46
Help!
I downloaded the GNU gcc compiler and accouterments from the FTP mirror site at
Oakland after getting a taste of it from some outdated archives on Compuserve.
I have no problems compiling stuff in ANSI C. However, C++ is another matter.
I use Borland Turbo C++ 3.1 for Windows. I tried compiling some example
programs from my old book on Turbo C++ for DOS, observing the use of ANSI C
comments instead of "//". Now I had problems.
As per the instructions in your FAQ, here is the information you request:
----------------------------------------------------------------------------
/*The contents of ENVIRON.LST -*/
CONFIG=DJGPP
COMSPEC=C:\COMMAND.COM
PROMPT=$p$g
C--=C:\C--
TEMP=C:\TEMP
PATH=C:\DOS;C:\DJGPP\BIN
DJGPP=c:/djgpp/djgpp.env
GO32TMP=c:/djgpp/tmp
---------------------------------------------------------------------------------
/*What go32 printed without parameters -*/
go32 version 1.12.maint3 Copyright (C) 1994 DJ Delorie
Lowest version I can run is 1.08
go32.exe usage: go32 [-d {debugger}] [{program} [{options} . . . ]]
go32.exe build time was Sun Dec 18 16:36:42 1994
VCPI (Expanded) memory available: 3712 Kb
Swap space available: 30880 Kb
---------------------------------------------------------------------------------
--------------
/* My system is a Pionex with an Intel 80486 DX-2 66Mhz processor. I have the
math co-processor (of course), and my C drive is double-spaced under DOS 6.2.
This has not presented a problem with any other compiler (I have 7), but I
suppose it may be relevent. I have a multi-config AUTOEXEC.BAT file, to wit: */
@ECHO OFF
PROMPT $p$g
SET C--=C:\C--
SET TEMP=C:\TEMP
GOTO %CONFIG%
REM Go to the section that matches the
REM current value of the CONFIG variable
:WINDOWS
SET EUDIR=C:\EUPHORIA
SET PATH=C:\TCWIN\BIN;C:\EUPHORIA\BIN;C:\PV;C:\CPS;C:\PCTOOLS;C:\DOS;C:\WINDOWS
C:\CPS\mirror h:
@LH /L:1,16944 C:\DOS\SHARE.EXE /l:500 /f:5100
LH /L:0;1,45456 /S C:\DOS\SMARTDRV.EXE
LH /L:1,37088 \MOUSE\MOUSE
SMARTDRV.EXE
SET LIB=C:\PV
SET INCLUDE=C:\PV
WIN
GOTO END
:DOS
SET BLASTER=A220 I7 D1 T4
@LH /L:1,16944 C:\DOS\SHARE.EXE /l:500 /f:5100
LH /L:0;1,45456 /S C:\DOS\SMARTDRV.EXE
LH /L:1,37088 \MOUSE\MOUSE
GOTO END
:DOOM
LH /L:1,37088 \MOUSE\MOUSE
GOTO END
:DJGPP
SET PATH=C:\DOS;C:\DJGPP\BIN
c:\djgpp\bin\setdjgpp c:\djgpp c:/djgpp
GOTO END
:END
---------------------------------------------------------------------------------
--------------------------------------
/* Here is my corresponding schizophrenic CONFIG.SYS file: */
[MENU]
MENUITEM=WINDOWS
MENUITEM=DOS
MENUITEM=DOOM
MENUITEM=DJGPP
MENUDEFAULT=WINDOWS, 10
[COMMON]
DOS=UMB
FILES=20
DEVICEHIGH /L:0;1,12112 /S =C:\DOS\DBLSPACE.SYS /MOVE
[WINDOWS]
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS
BUFFERS=30,0
FILES=30
LASTDRIVE=H
FCBS=16,8
STACKS=9,256
[DOS]
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS
FILES=15
SHELL=C:\COMMAND.COM C:\ /E:1000 /P
[DOOM]
[DJGPP]
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\DOS\EMM386.EXE NOEMS
DOS=HIGH
FILES=20
SHELL=C:\COMMAND.COM C:\ /E:1000 /P
[COMMON]
---------------------------------------------------------------------------------
--------------------------------------
/* Now for the fun part, what gcc printed onscreen during compile. It did not
"crash", really, it just won't finish the job on C++ files. */
c:\>gcc -v string4.cpp -o string
Reading specs from c:/djgpp/lib\specs
gcc version 2.6.3
c:/djgpp/bin\cpp.exe -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=6 -Dunix -Di386 -DGO32 -DMSDOS -D__unix__ -D__i386__ -D__GO32__
-D__MSDOS__ -D__unix -D__i386 -D__GO32 -D__MSDOS string4.cpp
c:/djgpp/tmp\cc000056
GNU CPP version 2.6.3 (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
c:/djgpp/cplusinc
c:/djgpp/include
/usr/local/lib/g++-include
/usr/local/include
/usr/local/go32/include
/usr/local/lib/gcc-lib/go32/2.6.1/include
/usr/include
End of search list.
c:/djgpp/bin\cc1plus.exe c:/djgpp/tmp\cc000056 -quiet -dumpbase string4.cc
-version -o c:/djgpp/tmp\cca00056
GNU C++ version 2.6.3 (80386, BSD syntax) compiled by GNU C version 2.6.3.
c:/djgpp/bin\as.exe -o c:/djgpp/tmp\cc00056 c:/djgpp/tmp\cca00056
c:/djgpp/bin\ld.exe -o string c:/djgpp/lib\crt0.o -Lc:/djgpp/lib
c:/djgpp/tmp\ccb00056 -lgcc -lc -lgcc
/* Then there's a whole slew of lines which are nearly identical*/
string4.cc(.text+0x174): undefined reference to 'cout'
string4.cc(.text+0x179): undefined reference to 'ostream::operator<<(char const
*)'
string4.cc(.text+0x189): undefined reference to 'cin'
string4.cc(.text+0x18e): undefined reference to 'istream::getline(char *, int,
char)'
...
/* Etc. For several screens. It gives you the idea; forgive me if I don't type
every single line! That's how it ends. No STRING file written. Nothing to run.
Nothing to debug.*/
---------------------------------------------------------------------------------
----------------------------------------------
/* Now, here's the source file - a really simple little ditty from an old
tutorial text */
/*
C++ program that demonstrates searching for the
characters and strings
*/
#include <iostream.h>
#include <string.h>
const unsigned STR_SIZE = 40;
main()
{
char mainStr[STR_SIZE+1];
char subStr[STR_SIZE+1];
char findChar;
char *p;
int index;
int count;
cout << "Enter a string: ";
cin.getline(mainStr, STR_SIZE);
cout << "Enter a search string: ";
cin.getline(subStr, STR_SIZE);
cout << "Enter a search character: ";
cin >> findChar;
cout << " 1 2 3 4\n";
cout << "01234567890123456789012345678901234567890\n";
cout << mainStr << "\n";
cout << "Searching for string " << subStr << "\n";
p = strstr(mainStr, subStr);
count = 0;
while(p){
count++;
index = p - mainStr;
cout << "Match at index" << index << "\n";
p = strstr(++p, subStr);
}
if (count == 0)
cout << "No match for search substring in main string\n";
cout << "Searching for character " << findChar << "\n";
p = strchr(mainStr, findChar);
count = 0;
while(p){
count++;
index = p - mainStr;
cout << "Match at index" << index << "\n";
p = strchr(++p, findChar);
}
if (count == 0)
cout << "No match for search character in main string\n";
return 0;
}
---------------------------------------------------------------------------------
---------------------------------------------------
I've tried using all kinds of command-line directives to make sure the proper
library and include files are found; I even matched the individual headers in
the djgpp\cplusinc directory to make sure there were no naming differences (I
only found 1 so far - "_string.h", but no "string.h") and adjusted the #include
directive accordingly. It made no difference. As far as I can tell through
studying the docs, I have things set up right. Be that as it may, I'm just a
rank amateur, and frankly, my eyes start to glaze over when I descend the ladder
toward assembly language. So be gentle with me, I beg you. Have I just missed
something really obvious? Or is there a compatibility problem with the "Turbo'
implementation of C++? The several programs I have attempted to compile uner
GNU C++ all compile and run fine as Turbo C++ "Easy Windows" apps with the
Borland 3.1 compiler. Hope someone there can help get me squared away.
Thanks in advance :-)
Wing Flanagan
Orlando, FL.
76451 DOT 2647 AT compuserve DOT com
- Raw text -