How to use STL with clang++?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use STL with clang++?

way_lzl

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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to use STL with clang++?

way_lzl
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 <[hidden email]>
To: [hidden email]
Subject: Re: [cfe-dev] How to use STL with clang++?
Date: 2010-12-23 11:31:40

2010/12/23 <[hidden email]>:

> 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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to use STL with clang++?

Sebastian Redl
In reply to this post by way_lzl
On 23.12.2010 04:11, [hidden email] 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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to use STL with clang++?

Juan Rubén Segovia
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 <[hidden email]>
On 23.12.2010 04:11, [hidden email] 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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to use STL with clang++?

Francois Pichet
In reply to this post by way_lzl


2010/12/22 <[hidden email]>

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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to use STL with clang++?

Francois Pichet
In reply to this post by Juan Rubén Segovia


2010/12/23 Juan Rubén Segovia <[hidden email]>
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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to use STL with clang++?

way_lzl
In reply to this post by way_lzl

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 <[hidden email]>
To: [hidden email]
Subject: Re: [cfe-dev] How to use STL with clang++?
Date: 2010-12-23 16:28:49

On 23.12.2010 04:11, [hidden email] 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
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev