delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/01/04:07:01

Date: Tue, 1 Apr 1997 11:53:21 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: JustIn <seismic AT geocities DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: C++ libgpp.a "undefined reference"?
In-Reply-To: <333FBEBB.3934@geocities.com>
Message-ID: <Pine.SUN.3.91.970401115243.19599A-100000@is>
MIME-Version: 1.0

On Mon, 31 Mar 1997, JustIn wrote:

> gxx -v -Zwin32 -c -O3 -m486 prog.cc
>  e:\dj/bin\as.exe -o prog.o c:\windows\temp\cccaaaaa
> gcc.exe: -lgpp: linker input file unused since linking not done
> gcc.exe: -lstdcx: linker input file unused since linking not done
> gcc.exe: -lm: linker input file unused since linking not done
> gxx -v -Zwin32 -O3 -m486 -o prog.tmp prog.o
> Reading specs from e:/dj/rsxntdj/lib\specs
> gcc version 2.7.2.1
>  e:\dj/bin\ld.exe -Le:/dj/rsxntdj/lib/all -o prog.tmp
> e:/dj/rsxntdj/lib\crt0win.
> o -Le:/dj/rsxntdj/lib\st -Le:/dj/rsxntdj/lib -Le:\dj/lib prog.o -lgpp
> -lstdcx -l
> m -Trsxnt.lnk -lalias -lgcc -lmain -lstati -lc -lc_app -lc -lgcc -lemx
> -lemx2 -l
> krn32 -lusr32 -lgdi32
> e:\dj/lib/libgpp.a(iostream.o)(.text+0xa67):iostream.cc: undefined
> reference to `__dj_ctype_flags'
> 
> *sigh*  I don't know enough about command-line compiling yet, and I'm
> probably doing something silly, maybe in the Makefile.  I've checked the
> installations many times over, used DJVERIFY 0.33a, and compiled other
> C/++ programs fine.

I've snipped parts of the log that you posted and left only what seems
to me as crucial clues to the source of your trouble.

First of all, you should know that you are living dangerously when you
use RSXNTDJ1 with DJGPP v2.01: RSXNTDJ was made for DJGPP v2.0, and so
might have problems with v2.01.  A new version is due in a few weeks,
according to announcement posted here not long ago.  So please treat
every error message you see with caution; in particular, I won't
recommend assuming that the problems you have are due to some stupid
mistake on your part: they might as well be very real.

Having said that, here's what I see in your log that might point to
the cause(s) of your trouble:

	1.  You use `gxx' to compile C++ programs.  Use `gcc' instead;
`gxx' is only for linking (see the suggested Makefile below).  This is
the cause of the "-lgpp: linker input file unused..." messages.

	2.  `__dj_ctype_flags' is in libc.a, so you need to understand
why does the linker complain about it although it gets -lc on its
command line *after* -lgpp.  One possibility is that the -Trsxnt.lnk
argument is in between.  It is possible that if you use `gcc' for
linking as well, that -T argument will be placed in its correct place
and your problem will be solved, so I suggest to try that (again, see
the Makefile below).

Failing all of the above, I would suggest sending your log to the
author of RSX and asking him for help.

Here's how I would write your Makefile:

-------------------------------------------
CFLAGS = -Zwin32 -Wall -O3 -m486
LDFLAGS = -Zwin32 -m486
LOADLIBES = -lgpp -lstdcxx -lm

OPT = rsxntopt
RM = rm -f

prog.exe : prog.o
	$(CXX) $(LDFLAGS) -o prog.tmp prog.o $(LOADLIBES)
	$(OPT) -b prog.exe -c -V
	$(RM) prog.tmp
------------------------------------------

Note that this makes extensive use of defaults built into GNU Make
(all of them described in the Make manual).  In particular, Make
already knows how to compile a .cc file into a .o file, you only need
to set the CFLAGS variable if you need non-default switches.  The
names CXX, LDFLAGS and LOADLIBES are also used by Make (see the
manual), therefore it is best to use them even if you override the
default rules, like in the case of producing prog.exe.  The default
value of CXX is `gcc'.

- Raw text -


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