Cent OS 6.7 中的 g++ 4.9.2 將編譯但無法鏈接

Cent OS 6.7 中的 g++ 4.9.2 將編譯但無法鏈接

我使用的是 Centos 6.7,並安裝了 devtools-3 發行版並「啟用」它以使 gcc 4.9.2 成為預設值。使用正規表示式的簡單 C++ 程式將進行編譯,但不會連結。

// regex_search example
#include <iostream>
#include <string>
#include <regex>

int main()
{
    std::string s("this subject has a submarine as a subsequence");
    std::smatch m;
    std::regex e("\\b(sub)([^ ]*)");   // matches words beginning by "sub"

    std::cout << "Target sequence: " << s << std::endl;
    std::cout << "Regular expression: /\\b(sub)([^ ]*)/" << std::endl;
    std::cout << "The following matches and submatches were found:" << std::endl;

    while (std::regex_search(s, m, e)) {
        for (auto x : m) std::cout << x << " ";
        std::cout << std::endl;
        s = m.suffix().str();
    }

    return 0;
}

答案1

我可以在這裡回答我自己的問題。對我來說這是一個愚蠢的錯誤。我沒有正確安裝 devtools-3 發行版。

相關內容