You are not logged in.

#1 2018-11-25 06:56:35

m_gustafsson
Member
Registered: 2011-08-30
Posts: 9

[Solved] How to fix a broken g++ installation

After updating my Arch Linux system on my laptop, I ran into a lot of compilation errors when trying to compile the c++ project I am working on. The same code compiles well on other Arch linux machines.

So, I tried a little hello world program, and it fails with the same error. My understanding is that the hello world program should be OK so the problem should be with my compiler, but I cannot figure out how to repair it. I have tried to rebuild base, base-devel, gcc and gcc-libs.

I have spent quite some time trying to figure out what is happening, but I get nowhere, so I would very much appreciate any hints.

The file I try to compile is very simple:

#include <iostream>

int main ()
{
    std::cout << "Hello, world!\n";
    return 0;
}


I compile it with:

$ g++ -Wall -Wfatal-errors hello.cpp -o hello

And the errors I get are:

In file included from /usr/include/c++/8.2.1/memory:74,
             from /usr/local/include/format.h:36,
             from /usr/local/include/time.h:11,
             from /usr/include/pthread.h:24,
             from /usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:35,
             from /usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/gthr.h:148,
             from /usr/include/c++/8.2.1/ext/atomicity.h:35,
             from /usr/include/c++/8.2.1/bits/ios_base.h:39,
             from /usr/include/c++/8.2.1/ios:42,
             from /usr/include/c++/8.2.1/ostream:38,
             from /usr/include/c++/8.2.1/iostream:39,
             from hello.cpp:4:
/usr/include/c++/8.2.1/ext/concurrence.h:124:5: error:
'__gthread_mutex_t' does not name a type; did you mean
'__pthread_mutex_s'?
__gthread_mutex_t _M_mutex;
^~~~~~~~~~~~~~~~~
__pthread_mutex_s
compilation terminated due to -Wfatal-errors

Last edited by m_gustafsson (2018-11-25 15:34:21)

Offline

#2 2018-11-25 07:26:26

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,565

Re: [Solved] How to fix a broken g++ installation

Rebuilding packages won't help when you're pulling things from /usr/local/. What are they and how did they get there?

Offline

#3 2018-11-25 09:08:43

m_gustafsson
Member
Registered: 2011-08-30
Posts: 9

Re: [Solved] How to fix a broken g++ installation

My problem is that I cannot build a very simple c++ program, so I assumed that my building environment is broken. Thus, I would like to rebuild that environment. The build environment packages was installed by me with pacman. But, maybe my problem is not with those packages?

Offline

#4 2018-11-25 10:49:02

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,396
Website

Re: [Solved] How to fix a broken g++ installation

In file included from /usr/include/c++/8.2.1/memory:74,
             from /usr/local/include/format.h:36,
             from /usr/local/include/time.h:11,

Those things in /usr/local are breaking your system.  Figure out how they got there and remove them.

Offline

#5 2018-11-25 15:33:40

m_gustafsson
Member
Registered: 2011-08-30
Posts: 9

Re: [Solved] How to fix a broken g++ installation

@Allan: thanks! I removed the two header files in /usr/local/include and now it all compiles.
@Scimmia: now I also got your point, thanks!

Offline

Board footer

Powered by FluxBB