way_lzl | 23 Dec 04:11 2010

How to use STL with clang++?

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? 

 

Thanks for your help



--Zhanglin

_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
way_lzl | 23 Dec 06:04 2010

Re: How to use STL with clang++?

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.
_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Sebastian Redl | 23 Dec 09:28 2010
Picon

Re: How to use STL with clang++?

On 23.12.2010 04:11, way_lzl@... wrote:
>
> 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:
>
>
There's more than one STL in this world. There's GCC's STL (libstdc++), 
which Clang fully supports up to version 4.2. There's Dinkumware's STL, 
a variant of which is shipped by Microsoft, which Clang does not yet 
support, since it uses lots of MS-specific extensions. There's also 
STLport, an independent project. You don't turn MS's STL to STLport, you 
replace the MSSTL with STLport when you switch to it. I assume Clang 
would support STLport, but you'd have to adapt the STLport configuration 
to recognize and correctly configure Clang. Or maybe someone already 
did; try googling.

We've got two or three people working on making MS's various headers 
work in Clang, but this stuff takes time.

Sebastian
_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Juan Rubén Segovia | 23 Dec 13:35 2010
Picon

Re: How to use STL with clang++?

Hi there! I am a new one here..


Contributing in this area sounds like a good start point to me. 
How could I get started working on the MSVC support in clang?

Cheers!
Juan


2010/12/23 Sebastian Redl <sebastian.redl-Qcow1E72b/EoPbFrRiQr9Q@public.gmane.org>
On 23.12.2010 04:11, way_lzl-k+cT0dCbe1g@public.gmane.org wrote:

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:


There's more than one STL in this world. There's GCC's STL (libstdc++), which Clang fully supports up to version 4.2. There's Dinkumware's STL, a variant of which is shipped by Microsoft, which Clang does not yet support, since it uses lots of MS-specific extensions. There's also STLport, an independent project. You don't turn MS's STL to STLport, you replace the MSSTL with STLport when you switch to it. I assume Clang would support STLport, but you'd have to adapt the STLport configuration to recognize and correctly configure Clang. Or maybe someone already did; try googling.

We've got two or three people working on making MS's various headers work in Clang, but this stuff takes time.

Sebastian

_______________________________________________
cfe-dev mailing list
cfe-dev-Tmj1lob9twrHfRtnQztjLA@public.gmane.orgu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Francois Pichet | 23 Dec 16:53 2010
Picon

Re: How to use STL with clang++?



2010/12/23 Juan Rubén Segovia <juanruben82-Re5JQEeQqe8@public.gmane.orgm>
Hi there! I am a new one here..

Contributing in this area sounds like a good start point to me. 
How could I get started working on the MSVC support in clang?

Cheers!
Juan

Great I really need help to improve MSVC compatibility.

I did some progress to improve MSVC compatibility in the last months. Up to now I limited myself to parsing the .h included with MSVC 2008 in -fsyntax-only mode. Currently all the .h without template code will parse correctly. I haven't really tried parsing any .c or .cpp files yet.

I suggest you download a large MSVC source code base, try to parse it with clang, see what the errors are and submit patches that will fix them to clang-commit.

Avoid source base that depends on MSVC template header files. They won't compile, this is something I am currently investigating but it is far from trivial. 

Another  thing: clang doesn't have a MSVC compatible driver. That could be a great project to work on. 


_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Francois Pichet | 23 Dec 13:45 2010
Picon

Re: How to use STL with clang++?



2010/12/22 <way_lzl-k+cT0dCbe1g@public.gmane.org>

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);


This particular error is because _invalid_parameter_noinfo is not defined at this point. 
I did an experiment where I flag everything as template dependent in Microsoft mode. 
It kinda work but i am not ready to submit anything yet about this.




_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
way_lzl | 24 Dec 08:19 2010

Re: How to use STL with clang++?

Sebastian

Thanks for your reply. I have tried to use STL header of tdm gcc 4.5.1, I don't have gcc 4.2.0 currently, in Mingw and link with ld. The normal STL string, vector, list etc work well. However a simple test case which is pasted below with iostream still can not work. The ld will report can not find external function  _dso_handle and _cxa_atexit. I have used -E option to find where it comes from. It seems LLVM compiler generate them. Some libraries are missed I guess. Could you help me check it?  Or could you help paste the compiler verbose output with -v? Or I have to use gcc 4.2.x?

 

By the way, which linker is recommended to use on Windows? MingW GNU ld or MSVC link? My LLVM is built with VS2005.

 

#include <string>
#include <iostream>

using namespace std;
int main()
{
    string str="test";
    cout << str;   
}

------------------------------------------------
--Zhanglin
----- Original Message -----
From: Sebastian Redl <sebastian.redl <at> getdesigned.at>
To: cfe-dev <at> cs.uiuc.edu
Subject: Re: [cfe-dev] How to use STL with clang++?
Date: 2010-12-23 16:28:49

On 23.12.2010 04:11, way_lzl <at> sina.com wrote:
>
> 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:
>
>
There's more than one STL in this world. There's GCC's STL (libstdc++),
which Clang fully supports up to version 4.2. There's Dinkumware's STL,
a variant of which is shipped by Microsoft, which Clang does not yet
support, since it uses lots of MS-specific extensions. There's also
STLport, an independent project. You don't turn MS's STL to STLport, you
replace the MSSTL with STLport when you switch to it. I assume Clang
would support STLport, but you'd have to adapt the STLport configuration
to recognize and correctly configure Clang. Or maybe someone already
did; try googling.

We've got two or three people working on making MS's various headers
work in Clang, but this stuff takes time.

Sebastian

_______________________________________________
cfe-dev mailing list
cfe-dev <at> cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
cfe-dev@...
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Gmane