You are not logged in.

#1 2018-02-27 09:05:54

johannkokos
Member
Registered: 2018-02-27
Posts: 12

[SOLVED] clang++5.0.1 regex linkage error

Trying to compile the following code with clang.

clang  -std=c++17  -stdlib=libc++ -lc++abi -Wall -Wextra -pedantic test.cpp

gcc-7 is perfectly fine with it.

clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

The full error is here: https://paste.ubuntu.com/p/kWFQwNTNS6/. (Ubuntu paste is awesome with no ads)

I tried it on compiler explorer. It's working fine(Clang version is 5.0.0 however). See https://godbolt.org/g/Sa1EN2

#include <iostream>
#include <regex>
#include <string>

int main()
{
  std::string pattern("[^c]ei");
  pattern = "[[:alpha:]]*" + pattern + "[[:alpha:]]*";
  std::regex r(pattern);
  std::smatch results;

  std::string test_string = "receipt friend theif receive";
  if (std::regex_search(test_string, results, r)) {
    std::cout << results.str() << std::endl;
  }
  return 0;
}

Last edited by johannkokos (2018-02-28 14:37:03)

Offline

#2 2018-02-28 10:30:11

kbw
Member
Registered: 2018-02-21
Posts: 1

Re: [SOLVED] clang++5.0.1 regex linkage error

Using ArchLinux.

When I use option

-stdlib=libc++

, I get error:

x3.cc:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
1 error generated.

When I use option

-lc++abi

, I get error:

/usr/bin/ld: cannot find -lc++abi
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)

Offline

#3 2018-02-28 11:38:12

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,740

Re: [SOLVED] clang++5.0.1 regex linkage error

Offline

#4 2018-02-28 14:36:12

johannkokos
Member
Registered: 2018-02-27
Posts: 12

Re: [SOLVED] clang++5.0.1 regex linkage error

Thanks.

Just found I am using a older version of libc++. Updating to 5.0.1 solves the problem.

Last edited by johannkokos (2018-02-28 14:37:36)

Offline

Board footer

Powered by FluxBB