www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/24/19:01:57

Date: Sat, 24 Jan 1998 13:19:24 -0800 (PST)
Message-Id: <199801242119.NAA03030@adit.ap.net>
Mime-Version: 1.0
To: kdawghu AT hotmail DOT com (Kris Mills), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Question about DJGPP and GXX and GCC

At 04:43  1/24/1998 GMT, Kris Mills wrote:
>I want to compile c++ code with djgpp i have been useing GXX because GCC won't 
>compile any thing i do in C++. I thought that GCC  would allow you to compile 
>c++ code also. Also when i type GCC at the dos it says no input file that's 
>COOL ! but when i type GXX it says
>
>e:/djgpp/lib\crt0.o(.data+0x92):crt0.s: undefined reference to `main'
>e:/djgpp/lib/libc.a(crt1.o)(.text+0x312):crt1.c: undefined reference to `main'
>
>is there some thing wrong with my setup up 
No, there's nothing wrong. `gcc' *will* compile and link C++ code if you
tell it to link the C++ libraries. `gxx' is just a convenience tool which
takes its command line, adds the options to link the C++ libraries, and
submits it to `gcc'. If `gcc' is told to link, but given only libraries and
no object file with a `main' function, confusion results giving this message.
Solution: Don't do that. :) If you're not sure how to compile, please see
(in this order) README.1ST, and the GCC info page "Invoking".
>
>Also it won't let me pass string types to the system function that is char *
>
>like
>
>#Include <iostream.h>
>#Include <string.h>
>#include <stdlib.h>
>
>main()
>
>{
>string text;
>cin >> text;
>system (text);
>}
This is a fairly wild guess, since my C++ knowledge is minimal, but I think
changing the following makes it work.
* You should #include <_string.h>, instead of <string.h> which is standard C
strings. (It really should be <String.h> but DOS can't tell the difference.)
* The type of text should be `String', with capital S.
* The argument to `system' should be `text.chars()' which returns the string
as a `char *'.

Btw, this is a standard C++ question and would be better directed to a
comp.lang.c++ newsgroup.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019