2016-07-22 172 views
0

我正試圖在Matlab上安裝Spams工具箱來優化稀疏表示問題。在OSX上使用clang ++進行編譯,但不能包含/查找頭文件

下載頁面級>http://spams-devel.gforge.inria.fr/downloads.html

在非常放在第一位,當我試圖用compile.m腳本編譯它,它說:

clang: error: unsupported option '-fopenmp' 
error: command 'clang' failed with exit status 1 

然後,我發現這後,我按照指令下面的,似乎以前的錯誤是固定


enter image description here


但現在,我得到的錯誤說:

...mexArchetypalAnalysis.cpp:32: 
./linalg/mexutils.h:15:10: 
fatal error: 'typeinfo' file not found 
#include <typeinfo> 

當我去到源文件和註釋此行,它給了我錯誤的,包括iostreamenter image description here

所以我可能認爲這是關於庫的問題,但我不熟悉C++或C的東西,我需要一些幫助。

+0

你安裝了命令行開發工具嗎?我已經失去了這些日子如何完成的軌跡 - 它已經改變了不同的時間,並且可能不是必需的。 –

+0

@JonathanLeffler我已經安裝了xocde select install – Microos

回答

0

最後,我固定這通過執行下面的步驟:

通過homebrew安裝 gcc編譯和openmp支持:

brew install gcc --without-multilib 

安裝後,在命令行

alias gcc=gcc-6 
alias clang=gcc-6 
alias g++=g++-6 

通過這樣做,您可以使用cpp編譯器支持openmp


讓我們運行一個測試程序,以檢查是否openmp正常工作:

#include <stdio.h> 
#include <omp.h> 

int print(int i){ 
    int tmp = 0; 
    for(int i=0;i<100000000;i++){ 
     tmp += 1; // time consuming loop 
    } 

    printf("%d\t",i); 
    return i; 
} 

int main(){ 

    #pragma omp parallel for 
    for(int i=0; i<10;i++){ 
     print(i); 
    } 
    return 0; 
} 

編譯:

gcc -fopenmp test.cpp -o run 

g++ -fopenmp test.cpp -o run 

輸出:

0 8 3 6 1 9 4 7 2 5 

正如你可以看到他們沒有在訂單打印,這正確地指示openmp作品。

相關問題