如何停止Intel icpc抱怨对basic_string的未定义引用?

时间:2019-11-19 09:26:05

标签: c++ icc

我正在尝试在MacOS上使用Intel icpc编译一个非常简单的程序。

// File: test.cpp
#include <iostream>
#include <string>

int main() {
    std::string s = "hello";
    std::cout << s << std::endl;
    return 0;
}

命令icpc -O2 -o test test.cpp输出

Undefined symbols for architecture x86_64:
  "__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1Emc", referenced from:
      _main in icpcDe7qot.o
ld: symbol(s) not found for architecture x86_64

我尝试使用icpc -O2 -o test test.cpp /usr/lib/libstdc++.dylib,但是它返回了相同的错误消息。 但是,使用g++clang++可以正常工作。

icpc的版本为icpc version 19.0.5.281 (gcc version 4.9.0 compatibility)

xcode的版本是

Xcode 11.2.1
Build version 11B500

MacOS的版本为10.15.1 (19B88)

有人可以告诉我如何正确链接库吗?

0 个答案:

没有答案