在windows上設定llvm+mingw環境變數
從網上下載了一個壓縮檔案-CODEBLOCKS20161122.rar-,解壓縮後目錄結構如下:
D:\CODEBLOCKS20161122 └─LLVM ├─bin ├─etc ├─i686-w64-mingw32 │ ├─bin │ ├─include │ │ ├─c++ │ │ │ ├─backward │ │ │ ├─bits │ │ │ ├─debug │ │ │ ├─decimal │ │ │ ├─experimental │ │ │ ├─ext │ │ │ │ └─pb_ds │ │ │ │ └─detail │ │ │ │ ├─binary_heap_ │ │ │ │ ├─binomial_hea │ │ │ │ ├─binomial_hea │ │ │ │ ├─bin_search_t │ │ │ │ ├─branch_polic │ │ │ │ ├─cc_hash_tabl │ │ │ │ ├─eq_fn │ │ │ │ ├─gp_hash_tabl │ │ │ │ ├─hash_fn │ │ │ │ ├─left_child_n │ │ │ │ ├─list_update_ │ │ │ │ ├─list_update_ │ │ │ │ ├─ov_tree_map_ │ │ │ │ ├─pairing_heap │ │ │ │ ├─pat_trie_ │ │ │ │ ├─rb_tree_map_ │ │ │ │ ├─rc_binomial_ │ │ │ │ ├─resize_polic │ │ │ │ ├─splay_tree_ │ │ │ │ ├─thin_heap_ │ │ │ │ ├─tree_policy │ │ │ │ ├─trie_policy │ │ │ │ └─unordered_it │ │ │ ├─i686-w64-mingw32 │ │ │ │ ├─bits │ │ │ │ └─ext │ │ │ ├─parallel │ │ │ ├─profile │ │ │ │ └─impl │ │ │ ├─tr1 │ │ │ └─tr2 │ │ ├─ddk │ │ ├─gdiplus │ │ ├─GL │ │ ├─psdk_inc │ │ ├─sdks │ │ ├─sec_api │ │ │ └─sys │ │ └─sys │ └─lib │ └─ldscripts ├─include │ ├─clang-c │ ├─gdb │ └─llvm-c ├─lib │ ├─clang │ │ └─3.6.0 │ │ ├─include │ │ │ └─sanitizer │ │ └─lib │ │ └─windows │ └─gcc │ └─i686-w64-mingw32 │ ├─4.9.1 │ │ ├─adainclude │ │ ├─adalib │ │ ├─finclude │ │ ├─include │ │ │ ├─objc │ │ │ └─ssp │ │ ├─include-fixed │ │ └─install-tools │ │ └─include │ └─lib ├─libexec │ └─gcc │ └─i686-w64-mingw32 │ └─4.9.1 │ └─install-tools ├─msbuild-bin ├─share │ └─clang └─tools └─msbuild ├─Win32 └─x64
編輯一個批處理檔案如下:
set MINGW_HOME=D:\CodeBlocks20161122\LLVM set MINGW_VERSION=4.9.1 set "PATH=%MINGW_HOME%\bin;%PATH%" set SS=i686-w64-mingw32 set "C_INCLUDE_PATH=%MINGW_HOME%\include;%MINGW_HOME%\%SS%\include" set "CPLUS_INCLUDE_PATH=%C_INCLUDE_PATH%;%MINGW_HOME%\%SS%\include;%MINGW_HOME%\%SS%\include\c++;%MINGW_HOME%\%SS%\include\c++\%SS%;%MINGW_HOME%\%SS%\include\c++\backward" set LLVM_HOME=D:\CodeBlocks20161122\LLVM set "PATH=%LLVM_HOME%\bin;%PATH%"
執行之後,就可以既用g++編譯,又用clang++編譯了。
D:\>g++ --version g++ (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 4.9.1 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. D:\>g++ p586_4a.cpp -o acpp1.exe p586_4a.cpp: In function 'int f(int, int)': p586_4a.cpp:59:17: warning: name lookup of 'a' changed fct(a,i); ^ p586_4a.cpp:8:5: warning: matches this 'a' under ISO standard rules int a[]= { ^ p586_4a.cpp:46:14: warning: matches this 'a' under old rules for (int a=1; a<=sqrtn; a++) ^ D:\>acpp1 16 :2 2 2 2 25 :5 5 f(10000,2)=2 cpp D:\>clang++ --version clang version 3.6.0 (216184) Target: i686-pc-windows-gnu Thread model: posix D:\>clang++ p586_4a.cpp -o acpp.exe p586_4a.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ 1 warning generated. D:\>acpp 16 :2 2 2 2 25 :5 5 f(10000,2)=2
換了一個mingw版本,能編譯,但最後出“無法定位程式輸入點”錯
D:\>g++ --version g++ (tdm-1) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. D:\>clang++ --version clang version 3.9.0 (branches/release_39) Target: i686-pc-windows-msvc Thread model: posix InstalledDir: D:\LLVM\bin D:\>g++ p530.cpp D:\>g++ p586_4a.cpp p586_4a.cpp: In function 'int f(int, int)': p586_4a.cpp:59:17: warning: name lookup of 'a' changed fct(a,i); ^ p586_4a.cpp:8:5: warning: matches this 'a' under ISO standard rules int a[]= { ^ p586_4a.cpp:46:14: warning: matches this 'a' under old rules for (int a=1; a<=sqrtn; a++) ^ --------------------------- as.exe - 無法找到入口 --------------------------- 無法定位程式輸入點 libiconv 於動態連結庫 libiconv-2.dll 上。 --------------------------- 確定 ---------------------------
我覺得已經接近真相了,問題出在3.8以上版本的llvm的官方編譯目標是 i686-pc-windows-msvc,
如果是i686-pc-windows-gnu,則能夠配合mingw
D:\>clang++ --version clang version 4.0.0 (trunk) Target: i686-pc-windows-msvc Thread model: posix InstalledDir: D:\LLVM\bin D:\>cd \llvm391 D:\LLVM391>bin\clang++ --version clang version 3.9.1 (branches/release_39) Target: i686-pc-windows-msvc Thread model: posix InstalledDir: D:\LLVM391\bin D:\LLVM391>cd \LLVM381 D:\LLVM381>bin\clang++ --version clang version 3.8.1 (branches/release_38) Target: i686-pc-windows-msvc Thread model: posix InstalledDir: D:\LLVM381\bin D:\LLVM381>cd \llvm371 D:\LLVM371>bin\clang++ --version clang version 3.7.1 (tags/RELEASE_371/final) Target: i686-pc-windows-gnu Thread model: posix ---- set MINGW_HOME=D:\win32sj\mingw32 set MINGW_VERSION=6.3.0 set "PATH=%MINGW_HOME%\bin;%PATH%" set SS=i686-w64-mingw32 set "C_INCLUDE_PATH=%MINGW_HOME%\include;%MINGW_HOME%\%SS%\include" set "CPLUS_INCLUDE_PATH=%C_INCLUDE_PATH%;%MINGW_HOME%\%SS%\include;%MINGW_HOME%\%SS%\include\c++;%MINGW_HOME%\%SS%\include\c++\%SS%;%MINGW_HOME%\%SS%\include\c++\backward" set GCC_INCPATH=%MINGW_HOME%\lib\gcc\%SS%\%MINGW_VERSION%\include set "CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%;%GCC_INCPATH%;%GCC_INCPATH%\c++;%GCC_INCPATH%\c++\%SS%;%GCC_INCPATH%\c++\backward" set LLVM_HOME=D:\LLVM371 set "PATH=%LLVM_HOME%\bin;%PATH%" D:\>g++ --version g++ (i686-win32-sjlj-rev1, Built by MinGW-W64 project) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. D:\>clang++ --version clang version 3.7.1 (tags/RELEASE_371/final) Target: i686-pc-windows-gnu Thread model: posix D:\>clang++ test.c clang++.exe: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated D:\>clang++ test.cpp
將llvm編譯成gnu版本的步驟,參見 MinGW-W64 編譯 LLVM 與 Clang
相關文章
- go 在 Windows 上環境變數GoWindows變數
- Mac上設定Java環境變數MacJava變數
- 設定環境變數變數
- win10 如何讓環境變數生效_windows10如何設定環境變數Win10變數Windows
- export 設定環境變數Export變數
- oracle環境變數設定Oracle變數
- CentOS環境變數設定CentOS變數
- redhatas 設定環境變數Redhat變數
- rman 設定環境變數變數
- JAVA環境變數設定Java變數
- 設定環境變數(轉)變數
- Windows下JAVA環境變數的設定祥解WindowsJava變數
- 在Linux中,什麼是環境變數?如何設定和檢視環境變數?Linux變數
- Qt 安裝與環境變數的設定(Windows 10)QT變數Windows
- Linux設定環境變數Linux變數
- c#環境變數設定C#變數
- XMLBeans 環境變數設定XMLBean變數
- Linux 環境變數設定Linux變數
- java JDK環境變數設定JavaJDK變數
- RMAN環境變數的設定變數
- java jdk 設定環境變數JavaJDK變數
- ansible 設定環境變數變數
- ansible設定環境變數變數
- 什麼是環境變數?Python中如何設定環境變數?變數Python
- Ant系列-在windows下配置環境變數Windows變數
- win10環境變數怎麼設定 win10設定環境變數的方法Win10變數
- windows配置環境變數Windows變數
- Golang環境變數設定詳解Golang變數
- JDK1.8環境變數設定JDK變數
- 環境變數的設定方法(轉)~變數
- Centos7環境變數設定CentOS變數
- Vue 設定環境變數和模式Vue變數模式
- CentOS 6.5 Oracle 環境變數設定CentOSOracle變數
- npm scripts設定環境變數方法NPM變數
- JDK 1.6環境變數如何設定?JDK變數
- Oracle 環境變數設定標準Oracle變數
- win 命令列 設定環境變數命令列變數
- 4.2.10.2 設定和取消設定環境變數變數