Clang:ARM Cross使用Threads编译C ++

时间:2017-06-27 19:55:06

标签: c++ clang cross-compiling clang++

我想编译这个简单的代码以在ARM架构(Android智能手机)上运行:

#include <iostream>
#include <thread>

static const int num_threads = 10;

void call_from_thread(int tid) {
    std::cout << "Launched by thread " << tid << std::endl;
}

int main() {
    std::thread t[num_threads];
    //Launch a group of threads
    for (int i = 0; i < num_threads; ++i) {
        t[i] = std::thread(call_from_thread, i);
    }
    std::cout << "Launched from the main\n";
    //Join the threads with the main thread
    for (int i = 0; i < num_threads; ++i) {
        t[i].join();
    }
    return 0;
}

使用Clang,我可以使用以下语句将此程序编译为本机体系结构(x86):

# clang++ test.cpp -std=c++11 -pthread

但是,交叉编译语句会返回错误:

# clang++ test.cpp -std=c++11 -pthread -target armv7a-none-linux-eabi
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^
1 error generated.

有人可以帮助我或给我一些提示吗?

0 个答案:

没有答案