Advertisement

Query about gcc

Started by July 23, 2002 12:03 PM
16 comments, last by Enigma 22 years, 3 months ago
That''s what I would have expected, expecially as the error message mentions Class::Class(&Class) as a candidate. The Borland compiler certainly adds copy constructors for you if you don''t define them yourself.

However, having said all of that it appears that C-Junkie did hit the nail on the head - Having added a copy constructor and changed it and all existing copy constructors to class::class(const class& name) instead of class::class(class& name) the program compiles fine (It doesn''t link yet, but it compiles!).

Does anyone know why the parameter to the copy constructor needs to be const? I had a look around the web but every tutorial just uses const, none of them explain why. Under Borland I''ve never had to use const.

Cheers,

Enigma
Another problem

I've gotten rid of all the link errors that I understand, but I'm left with the following list of errors:
temp: In function `__divdi3':/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(.rodata+0x0): multiple definition of `_fp_hw'/usr/lib/crt1.o(.rodata+0x0): first defined heretemp: In function `_init':temp(.init+0x0): multiple definition of `_init'/usr/lib/crti.o(.init+0x0): first defined heretemp: In function `_start':temp(.text+0x0): multiple definition of `_start'/usr/lib/crt1.o(.text+0x0): first defined heretemp: In function `__divdi3':/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(.fini+0x0): multiple definition of `_fini'/usr/lib/crti.o(.fini+0x0): first defined heretemp: In function `__divdi3':/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(*ABS*+0x804a708): multiple definition of `_GLOBAL_OFFSET_TABLE_'/usr/lib/crt1.o(.got.plt+0x0): first defined heretemp: In function `__divdi3':/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(.rodata+0x4): multiple definition of `_IO_stdin_used'/usr/lib/crt1.o(.rodata+0x4): first defined heretemp: In function `__divdi3':/usr/src/build/87732-i386/BUILD/gcc-2.96-20000731/obj-i386-redhat-linux/gcc/../../gcc/libgcc2.c(.data+0x0): multiple definition of `__data_start'/usr/lib/crt1.o(.data+0x0): first defined here/usr/lib/crt1.o(.dynamic+0x0): multiple definition of `_DYNAMIC'collect2: ld returned 1 exit status

It looks to me like the headers I'm including are conflicting or messed up and redefining things. Does anyone have any idea what's going on here and whether it's likely to be because of my code, because of any odd headers I may be including, or because the headers are messed up?

Cheers,

Enigma

[edited by - Enigma on July 26, 2002 11:12:57 AM]
Advertisement
looks to me like your object files already have libraries linked with them...

Can we see you Makefile (or relevant portions of it)

or are you doing this by hand? (or some ide?)
This is all done by hand!

The command line I use is:

g++ -o <filename> <list of cpp files>

Unfortunately I can't remember all the files at the moment - If it'll help I can post them tommorrow when I have access to the unix machine they're currently stored on. All the files I compile are my own c++ files and there are no libraries. I suspect that something messed up when I installed gcc 3.1, but I don't know enough about gcc to be sure. Interestingly I got an error when running a very simple program (literally just print a line to cout). It was something to do with a shared library. I'll post details tommorrow when I can reproduce it.

Thanks for your continuing help,

Enigma

Edit: tags!

[edited by - Enigma on July 28, 2002 6:07:56 PM]
OK, I''ve compiled it on a different machine and it linked fine (segfaults during execution, but it linked OK) - looks like I''m going to have to reinstall gcc on the old machine.

Enigma
Yay!!

It works!!

For some unknown reason the code compiled and linked fine on my old machine this morning. I still have a problem with gcc 3.1, any program compiled with it gives the following error:
error while loading shared libraries: libstdc++.so.4:cannot open shared object file: No such file or directory

I''ll have a play around and see if I can fix it.

Cheers for all your help guys and be warned - I have a lot of coding left to do - I may well be back!!!

Cheers

Enigma
Advertisement
thats jsut a missing library... but it should ahve come with gcc, i think
Yep, all I had to do was set the library path!

Cheers,

Enigma

This topic is closed to new replies.

Advertisement