2017-03-02 102 views
3

我只是在學習如何編碼。鐺++(版本5)和LNK4217警告

我已經安裝鐺版本5在Windows中使用的Visual Studio 14

10系統,我創建一個Hello World的cpp文件來測試工作。

示例代碼

#include <iostream> 
using namespace std; 

int main() 
{ 
    cout << "Hello World!\n"; 
    int rip{1}; 
    int dal{4}; 

    int kane = rip + dal; 

    cout << kane; 
    return 0; 
} 

命令

clang++ -o .\bin\testing.exe test.cpp 

鏘不編譯,我得到它並不如預期運行的可執行文件。但我確實收到了這條消息。

test-3e53b3.o : warning LNK4217: locally defined symbol ___std_terminate imported in function "int `public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)'::`1'::dtor$5" ([email protected][email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]@4HA) 
test-3e53b3.o : warning LNK4217: locally defined symbol [email protected] imported in function "public: void __thiscall std::ios_base::clear(int,bool)" ([email protected][email protected]@@[email protected]) 

我在網上搜索,可以找到類似的問題,但他們是不一樣的。

我意識到這可能對你們很簡單,但我很茫然,我使用了各種IDES和GCC,並且此代碼之前沒有產生此警告。

回答

11

-Xclang -flto-visibility-public-std添加到您的編譯器選項。

像這樣:

clang++ -Xclang -flto-visibility-public-std -o test.exe test.cpp

編輯:

或者使用鐺-CL代替:

clang-cl -o test.exe test.cpp

+6

作品,但爲什麼呢?什麼是clang-cl,選項有什麼作用? – bugybunny