我正在尝试在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)
有人可以告诉我如何正确链接库吗?