Robin
Robin

Reputation: 311

clang++ (version 5) and LNK4217 warning

I am just learning how to code.

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

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

Sample code

#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;
}

command

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

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.

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.

Upvotes: 21

Views: 5771

Answers (1)

JayPhi
JayPhi

Reputation: 361

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

Like so:

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

Edit:

Or use clang-cl instead:

clang-cl -o test.exe test.cpp

Upvotes: 34

Related Questions