Mail Archives: djgpp/1999/04/10/11:49:49
On 10 Apr 99, at 0:37, David Whitcombe wrote:
Try compiling with optimizations (gcc -O2 ...). As far as I remember it helped
when I had similar problems.
> I read the FAQs (at least, all the FAQs I could find) I searched on
> delorie.com
> through the mail archives. I fiddled, I tweaked. I read all the headers in
> %DJDIR%/lang/cxx
>
> This fails:
> ---------------------------------
> #include <_String.h>
>
> int main(void)
> {
> String x="Straw? No, too stupid. I put soot on warts.";
> String y=x;
> if (x==y) printf("Sit on a potato pan, Otis.");
> return 0;
> }
> ---------------------------------
>
> It chokes during link with:
> -----------------
> Error: test.o: In function `main':
> test.cpp(1) Error: undefined reference to `String::String(char const *)'
> test.cpp(2) Error: undefined reference to `String::String(String const &)
> test.cpp(3) Error: undefined reference to `operator==(String const &, Str
> test.cpp(4) Error: undefined reference to `String::~String(void)'
> Error: test.cpp(.text+0xc3): undefined reference to `String::~String(void
> Error: test.cpp(.text+0xf7): undefined reference to `String::~String(void
> Error: test.cpp(.text+0x117): undefined reference to `String::~String(voi
> There were some errors
> --------------------------------------
> No doubt.
>
> The command that RHIDE is using to do the link is:
> ------------
> gcc -o test.exe test.o -lgpp -lstdcxx
>
> I'm using libgpp2.8.1.1, gcc2.8.1, and rhide 1.4 (although, that doesn't
> seem to matter,
> as when I type the commands myself, it fails just as wonderfully).
>
> I read on the mail archives that this might be a libgpp2.8 binary
> distribution bug, where
> someone wrote that when he compiled with optimization, the error
> disappeared, due
> to the fact that all the methods are declared inline in _String.h, and
> something mysterious
> happens to them when optimizations are turned off.
>
> Does this make sense?
>
>
> I can do other C++ stuff, like iostreams, and it doesn't complain one whit.
> The compiler doesn't complain until link time.
>
> I'm new to comp.os.msdos.djgpp, but not to C and C++...
> Any suggestions would be mightily appreciated, as, though fond as I am of
> reinventing
> wheels, I'd really rather not write another string class.
>
> I'm tired of writing string classes.
>
>
>
> "Hear about the new object oriented cobol? It's called
> Add_one_to_cobol_and_store_result_in_cobol."
>
>
>
>
- Raw text -