codeapp icon indicating copy to clipboard operation
codeapp copied to clipboard

无法使用C++ STL库

Open yeahQing opened this issue 5 years ago • 3 comments

头文件包含 <vector> 链接时会报错


#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    cout << "Hello World!";
    cout << 1 + 2 << endl;
    cout << floor(7/3) << endl;

    vector<int> nums;

    nums.push_back(1);

    cout << nums[0] << endl;

    return 0;
}

报错如下 wasm-ld: error: undefined symbol: __cxa_allocate_exception wasm-ld: error: undefined symbol: __cxa_throw clang++: error: linker command failed with exit code 1 (use -v to see invocation) wasm: file a.out not found

yeahQing avatar Nov 12 '21 03:11 yeahQing

使用远程的Clang和GCC都是可以编译的,但是本地的Clang不行

yeahQing avatar Nov 12 '21 03:11 yeahQing

clang++ main.cpp -fno-exceptions

bummoblizard avatar Nov 12 '21 06:11 bummoblizard

clang++ main.cpp -fno-exceptions

感谢!已经成功解决。想问一下在哪里修改运行执行的终端命令呢?

yeahQing avatar Nov 12 '21 15:11 yeahQing