samedi 13 novembre 2021

gcc and clang: thread library is successfully included but nothing won't be compiled with that

I've got specific error that I haven't encountered before.

Before I'll start, I need to say that I work on a server and have no root rights. /usr/bin and /usr/local/bin are missing many packages and because of that I had been obliged to install necessary packages (including gcc-5.4.0) locally in my $HOME directory and everything worked fine until today

Something happened and since I cannot compile any program that uses <thread>, <mutex> and anything that related to multithreading. It throws many errors in log like (this is llvm building error):

mutex.h:69:14: error: ‘condition_variable’ in namespace ‘std’ does not name a type
 typedef std::condition_variable Condition;

I've been looking for solution and many say that you need to pass -std=c++11 flag. I think that this is not the reason, but I found something interesting:

I created a simple program just to check whether it can be compiled:

#include <mutex>

std::mutex m;

int main() {}
  1. Used locally installed g++: $HOME/g++ -std=c++11 -lpthread mut.cc: FAILED
  2. Used globally installed g++: /usr/bin/g++ -std=c++11 -lpthread mut.cc: SUCCESS

I suppose this error somehow related to linking with libpthread. The same happens with locally installed clang++

Aucun commentaire:

Enregistrer un commentaire