You should link msvcrt as well.

su 23. jouluk. 2018 klo 2.25 Maarten Verhage ([email protected])
kirjoitti:
>
> Hi Liu, Martin and others,
>
> With both of you we mentioned the idea of building the LLVM libc++ with
> mingw gcc on Windows. This in order to get C++11 functionality in the Mingw
> win32-seh variant. Which in turn could be used to build LLVM and clang.
>
> I hope this LLVM related question is suitable for this mailing list. Still
> it depend strongly on mingw64.
>
> I was able to get the static library libc++.a out of it. My cmake command
> line was:
>
> cmake -G "MinGW Makefiles" ^
> -DCMAKE_BUILD_TYPE=Release ^
> -DLIBCXX_HAS_WIN32_THREAD_API=ON ^
> -DLIBCXX_ENABLE_SHARED=OFF ^
> -DLIBCXX_ENABLE_STATIC=ON ^
> -DLIBCXX_ENABLE_EXCEPTIONS=ON ^
> -DCMAKE_CXX_COMPILER=g++ ^
> -DCMAKE_CXX_FLAGS="-D_LIBCPP_BUILDING_LIBRARY -D_WIN32_WINNT=0x0600" ^
> -DCMAKE_INSTALL_PREFIX="t:/libcxx_install/release" ^
> -S..\libcxx ^
> -BT:\libcxx_build > libcxx_cmake_result.txt 2>&1
>
> Then I build the makefile. The result of that is in the attachment
> libcxx_build_result.txt. Would you be willing to check if these compile
> warning look harmless? I didn't build libc++abi yet. Because I'm missing the
> knowledge to see what role it has.
>
> I wasnt sure where I would need to start with the official LLVM tests of
> libc++ using LIT. Do you know how I would need to setup the test environment
> in pure Windows?
>
> So instead I set out to write a little program and see if I could manage to
> tell gcc to use the LLVM libc++ and see if it compiles and links correctly.
>
> #include <cstddef>
> #include <cstdio>
> #include <cstdint>
> // include string to see if it actually uses the llvm libc++ library
> #include <string>
>
> int main()
> {
>   std::string str("Hello, world\n");
>
>   printf( str.c_str() );
>   getchar();
>   return 0;
> }
>
> Here is my makefile:
> FLAGS = -std=c++14 -pedantic -Wextra -Wlogical-op
> INCPATH_LLVM_LIBCXX = -I"C:\dev\libcxx_install\release\include\c++\v1"
> LIBPATH_LLVM_LIBCXX = -L"C:\dev\libcxx_install\release\lib"
> MINGW64_PATH =
> "C:\dev\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\x86_64-w64-mingw32"
> INCPATH_WIN = -I"$(MINGW64_PATH)\include"
> LIBPATH_WIN = -L"$(MINGW64_PATH)\lib"
>
> LIBSWIN = -l:libkernel32.a -l:libuser32.a -l:libshell32.a -l:libadvapi32.a\
>  -l:libws2_32.a -l:liboleaut32.a -l:libimm32.a -l:libwinmm.a -l:libole32.a\
>  -l:libuuid.a -l:libopengl32.a -l:libole32.a -l:libgdi32.a
>
> all: test.exe
>
> test.exe : test.o
>  g++ -v -nodefaultlibs -static -mconsole test.o
> $(LIBPATH_LLVM_LIBCXX) -l:libc++.a -l:libgcc_s.a -l:libgcc.a
> $(LIBSWIN) -Wl,-Map,test_map.txt -o test.exe > link_result.txt 2>&1
>
> test.o : test.cpp
>  g++ -v -c -nostdinc++ -nostdlib $(INCPATH_LLVM_LIBCXX) $(FLAGS) test.cpp
>
> clean:
>  del test.o test.exe
>
> It seems to compile but it fails with link. Please see link_result.txt. A
> whole bunch of undefined references. Some specific to mingw as well as the
> standard C library. But I could not find libc.a in the mingw build.
>
> On the LLVM documentation website:
> https://libcxx.llvm.org/docs/UsingLibcxx.html#using-libc-with-gcc
> there is a section called “Using libc++ with GCC” which demonstrates the
> static gcc libraries to link with. These
> are: -lc++ -lc++abi -lm -lc -lgcc_s –lgcc.
>
> But I cannot find a libc.a or a libm.a library files in the mingw64 builds
> like x86_64-8.1.0-release-win32-seh-rt_v6-rev0 for example.
>
> My questions are:
>
> What should I do to make this little program to link?
> Is there an internet resource where I can learn what all the mingw64
> supplied static libraries are used for? Like libsupc++.a, libgcc_eh.a. And
> where the standard C library is hidden?
>
> Thanks a lot for your time!
>
> Best regards,
> Maarten Verhage
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to