[cfe-dev] Linking with clang in gcc mode on Windows

Edward Diener eldlistmailingz at tropicsoft.com
Sun Jul 13 08:00:26 PDT 2014


On 7/12/2014 5:09 AM, Yaron Keren wrote:
> Hi
>
> You need -lstdc++ in linking stage, both with gcc and clang.

Thanks for the information. I realized that if I used clang++ rather 
than clang the stdc++ library is automatically found. Everything now 
works properly.

>
> Yaron
>
>
>
> 2014-07-12 1:53 GMT+03:00 Edward Diener <eldlistmailingz at tropicsoft.com
> <mailto:eldlistmailingz at tropicsoft.com>>:
>
>     I built the latest clang on Windows in gcc mode using Cmake and
>     Ninja. When I compile a source file all the gcc header files are
>     found and the compilation succeeds but when I link none of the gcc
>     libraries appear to be found. Here is the compilation output for a
>     single source file:
>
>         clang-linux.compile.c++.__without-pth
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj
>
>
>         "C:/Programming/__VersionControl/bninja___installed_clang/bin/clang.exe"
>         -c -x c++ -O0 -g -fno-inline -Wall -g  -DBOOST_ALL_NO_LIB=1
>         -I"..\..\.." -o
>         "..\..\..\bin.v2\libs\mpl\__test\bool.test\clang-linux-3.__5.0\debug\bool.obj"
>         "bool.cpp"
>
>
>     Here is the error output for the link step:
>
>         clang-linux.link
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.exe
>
>
>         "C:/Programming/__VersionControl/bninja___installed_clang/bin/clang.exe"
>             -o
>         "..\..\..\bin.v2\libs\mpl\__test\bool.test\clang-linux-3.__5.0\debug\bool.exe"
>         -Wl,--start-group
>         "..\..\..\bin.v2\libs\mpl\__test\bool.test\clang-linux-3.__5.0\debug\bool.obj"
>           -Wl,-Bstatic  -Wl,-Bdynamic  -Wl,--end-group -g
>
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj:
>         In function `_cxx_global_var_init':
>         c:/MinGW/lib/gcc/mingw32/4.8.__1/include/c++/iostream:74:
>         undefined reference to `std::ios_base::Init::Init()'
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj:
>         In function `_dtor__ZStL8__ioinit':
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/__bool.cpp:74:
>         undefined reference to `std::ios_base::Init::~Init()'
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj:
>         In function `ZN5boost13report_errorsEv':
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:130:
>         undefined reference to `std::cerr'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:132:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:132:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::endl<char, std::char_traits<char>
>          >(std::basic_ostream<char, std::char_traits<char> >&)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:132:
>         undefined reference to `std::ostream::operator<<(std:__:ostream&
>         (*)(std::ostream&))'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::cerr'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::ostream::operator<<(int)__'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::endl<char, std::char_traits<char>
>          >(std::basic_ostream<char, std::char_traits<char> >&)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:138:
>         undefined reference to `std::ostream::operator<<(std:__:ostream&
>         (*)(std::ostream&))'
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj:
>         In function `ZN5boost6detail16test_failed___implEPKcS2_iS2_':
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:65:
>         undefined reference to `std::cerr'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::ostream::operator<<(int)__'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::operator<<
>         <std::char_traits<char> >(std::basic_ostream<char,
>         std::char_traits<char> >&, char const*)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::basic_ostream<char,
>         std::char_traits<char> >& std::endl<char, std::char_traits<char>
>          >(std::basic_ostream<char, std::char_traits<char> >&)'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:66:
>         undefined reference to `std::ostream::operator<<(std:__:ostream&
>         (*)(std::ostream&))'
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj:
>         In function `ZN5boost6detail20report___errors_remindEv':
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:53:
>         undefined reference to `__cxa_guard_acquire'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:53:
>         undefined reference to `__cxa_guard_release'
>         C:\Programming\VersionControl\__modular-boost\libs\mpl\test/..__\..\..\boost/core/lightweight___test.hpp:55:
>         undefined reference to `__cxa_guard_abort'
>         ..\..\..\bin.v2\libs\mpl\test\__bool.test\clang-linux-3.5.0\__debug\bool.obj:(.eh_frame+__0x12b):
>         undefined reference to `__gxx_personality_v0'
>         collect2.exe: error: ld returned 1 exit status
>         clang.exe: error: linker (via gcc) command failed with exit code
>         1 (use -v to see invocation)
>
>
>     Anybody have any idea why the link is failing ? It looks like clang
>     is not searching any library paths but maybe it is something else.
>
>     _________________________________________________
>     cfe-dev mailing list
>     cfe-dev at cs.uiuc.edu
>     <mailto:cfe-dev at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/__mailman/listinfo/cfe-dev
>     <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>





More information about the cfe-dev mailing list