clang ++(版本5)和LNK4217警告 [英] clang++ (version 5) and LNK4217 warning

查看:124
本文介绍了clang ++(版本5)和LNK4217警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何编码.

我已使用Visual Studio 14在Windows 10系统上安装了clang版本5.

I have installed clang version 5 on a windows 10 system using visual studio 14.

我创建了一个hello world cpp文件来进行测试.

I created a hello world cpp file to test that is working.

示例代码

#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

Clang确实可以编译,并且我得到了一个可以按预期运行的可执行文件.但是我确实收到了此消息.

Clang does compile and I get an executable which does run as expected. however I do receive this message.

    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" (?dtor$5@?0???1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ@4HA)
test-3e53b3.o : warning LNK4217: locally defined symbol __CxxThrowException@8 imported in function "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z)

我已经在网上搜索过,可以找到类似的问题,但是它们并不相同.

I have searched online and can find similar issues but they are not the same.

我意识到这对您来说可能很简单,但是我不知所措,我使用了各种IDES和GCC,并且此代码之前并未产生此警告.

I realise this maybe simple to you guys, but I am at a loss I have used various IDES and GCC and this code has not produced this warning before.

推荐答案

在您的编译器选项中添加 -Xclang -flto-visibility-public-std .

Add -Xclang -flto-visibility-public-std to your compiler options.

像这样:

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

或改用 clang-cl :

clang-cl -o test.exe test.cpp

这篇关于clang ++(版本5)和LNK4217警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆