[cfe-dev] How to use STL with clang++?

way_lzl at sina.com way_lzl at sina.com
Wed Dec 22 21:04:23 PST 2010


Paul
 
Thanks for your suggestion. I have used mingw GCC's STL headers with an extra macro__MSVCRT_
_ without which compiler reports fgetws is not declared, then the compilation is OK but link has error. 
------------------------------------------------
 $ clang++  -I/c/mingw/lib/gcc/mingw32/4.5.1/include/c++/ -I/c/mingw/lib/gcc/min
gw32/4.5.1/include/c++/mingw32 -I/c/mingw/lib/gcc/mingw32/4.5.1/include/c++/bac
kward -I/c/MinGW/lib/gcc/mingw32/4.5.1/../../../../include -I/c/MinGW/lib/gcc/m
ingw32/4.5.1/include -I/c/MinGW/lib/gcc/mingw32/4.5.1/include-fixed -D__MSVCRT_
_ str.cpp
cc-000000.o : error LNK2001: unresolved external symbol __ZNSaIcEC1Ev
cc-000000.o : error LNK2001: unresolved external symbol __ZNSsC1EPKcRKSaIcE
cc-000000.o : error LNK2001: unresolved external symbol __ZNSaIcED1Ev
cc-000000.o : error LNK2001: unresolved external symbol __ZNSsD1Ev
a.out : fatal error LNK1120: 4 unresolved externals
------------------------------------------------
 
After using -v I noticed the LLVM uses MSVC's linker, so I just tried GCC's linker, it runs OK. 
 
But... If I used iostream, the GCC's linker will report undefiend reference to _dso_handle and _cxa_atexit.
 
Any suggestion? Thanks.

--Zhanglin

----- Original Message -----
From: Paul Davey <plmdvy at gmail.com>
To: way_lzl at sina.com
Subject: Re: [cfe-dev] How to use STL with clang++?
Date: 2010-12-23 11:31:40

2010/12/23 <way_lzl at sina.com>:
> Hello all
>
>
>
> Anyone can help me use STL with clang++? My LLVM+Clang was compiled with
> MSVC8 on Windows7. then I found \Microsoft Visual Studio 8\VC\include is set
> as the default header file searching path. But c++ with STL will report
> errors as below:
>
> ----------------------------------------------------------------------------------------------
>
> C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include/iosfwd(212) :
> error
> :
> no member named '_invalid_parameter_noinfo' in the global namespace;
> did
> you mean '_invalid_parameter_handler'?
> _SCL_SECURE_CRT_VALIDATE(_Dest_size >= _Count, NULL);
>
> ----------------------------------------------------------------------------------------------
>
>
>
> I guess MSVC's STL is compatible then turned to STLport, but it still can
> not work neither.
>
> ----------------------------------------------------------------------------------------------
>
> In file included from ../STLport-5.2.1/stlport/stl/config/_system.h:160:
> ../STLport-5.2.1/stlport/stl/config/_windows.h(108) : error: unknown type
> name
> '_STLP_IMPORT_DECLSPEC'
>
> ----------------------------------------------------------------------------------------------
>
>
>
> However the LLVM's online compiler http://llvm.org/demo/ can compile STL
> successfully. Anything is wrong? Anything I missed? Or I need llvm-gcc?
>
clang++ cannot use msvc's c++ headers yet. You must use mingw's STL
headers and library. This should happen if you build it with mingw
automatically. Otherwise you have to change a bunch of things, using
ti with msvc is experimental and the C++ is not going to work unless
you use no standard libs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101223/abb37673/attachment.html>


More information about the cfe-dev mailing list