You are not logged in.

#1 2020-11-26 14:40:32

TJM
Member
Registered: 2016-09-18
Posts: 118

[CLOSED] Wired behaviour of GCC

I'm getting a very wired behaviour of the latest gcc from pacman. It's too wired that I could demonstrate it with a simple example:

[tjm@ArchPad tmp]$ tee poc.cc <<<'#include <iostream>'
#include <iostream>
[tjm@ArchPad tmp]$ gcc ./poc.cc 
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
/usr/bin/ld: /tmp/ccqFo8tS.o: in function `__static_initialization_and_destruction_0(int, int)':
poc.cc:(.text+0x25): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: poc.cc:(.text+0x3a): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
[tjm@ArchPad tmp]$ 

I have tried reinstall gcc and  binutils. However, it didn't help. Anyone have any ideas on how to fix this?

Last edited by TJM (2020-11-26 14:55:33)

Offline

#2 2020-11-26 14:46:45

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [CLOSED] Wired behaviour of GCC

By adding a main function?

Offline

#3 2020-11-26 14:48:29

TJM
Member
Registered: 2016-09-18
Posts: 118

Re: [CLOSED] Wired behaviour of GCC

Scimmia wrote:

By adding a main function?

That doesn't help either.

[tjm@ArchPad tmp]$ cat poc.cc 
#include <iostream>

int main() {
	return 0;
}
[tjm@ArchPad tmp]$ gcc ./poc.cc 
/usr/bin/ld: /tmp/ccoDqwYo.o: in function `__static_initialization_and_destruction_0(int, int)':
poc.cc:(.text+0x30): undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: poc.cc:(.text+0x45): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
[tjm@ArchPad tmp]$ 

Last edited by TJM (2020-11-26 14:48:51)

Offline

#4 2020-11-26 14:52:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,516
Website

Re: [CLOSED] Wired behaviour of GCC

I can confirm the output if I try - as you are doing - to compile c++ code with a c compiler.  That's not very surprising.  Use g++ for that.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2020-11-26 14:54:17

TJM
Member
Registered: 2016-09-18
Posts: 118

Re: [CLOSED] Wired behaviour of GCC

Trilby wrote:

I can confirm the output if I try - as you are doing - to compile c++ code with a c compiler.  That's not very surprising.  Use g++ for that.

Ahh, that helps. Thanks.

Offline

#6 2020-11-26 15:00:40

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,361

Re: [CLOSED] Wired behaviour of GCC

Please use [SOLVED] rather than [CLOSED] to denote solved threads

Offline

Board footer

Powered by FluxBB