2017-03-02 85 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

相关问题