Hi Liu,

Thanks for your message. No I'm sorry, I shouldn't ask about LLVM specific 
things. I should have more patience.

Also I should have known to link at least with libmsvcrt.a too.

But as for the mingw/gcc libraries under nodefaultlibs I would have never 
guessed I should specify something like:
`-lmingw32 -lgcc -lgcc_eh -lmingwex -lgcc -lgcc_eh -lmsvcrt

So, I'm glad I asked you about this.

> `libsupc++` is the C++ support library that provides RTTI for
> fundamental types, global `operator new` and `operator delete`
> functions, thread-safe local static initialization, thread-local storage
> support (emulated) etc. It is purely provided as a static library,
> because libstdc++ has it encapsulated and if you want to link against
> libsupc++ dynamically you will be linking against libstdc++.

I learned that LLVM libc++abi provide equivalent facilities as libsupc++. As 
I'm using libc++ I thought it would be best to also use libc++abi then. So I 
build a static libc++abi and linked it with my libc++.

Now the link of of my example code goes much better. As much more of the 
implementation is found in libraries.
The link command for my example code:

g++ -v -nodefaultlibs -static -mconsole test.o 
$(LIBPATH_LLVM_LIBCXX) -l:libc++.a -l:libmingw32.a -l:libgcc_s.a -l:libgcc.a 
 -l:libmingwex.a -l:libgcc_s.a -l:libgcc.a -l:libmsvcrt.a 
$(LIBSWIN) -Wl,-Map,test_map.txt -o test.exe > link_result.txt 2>&1

link gives one undefined reference:
libmsvcrt.a(lib64_libmsvcrt_os_a-__p__fmode.o):__p__fmode.c:(.rdata$.refptr.__imp__fmode[.refptr.__imp__fmode]+0x0):
 
undefined reference to `__imp__fmode'

I think it has something to do with the crtbegin.o and crtend.o, because the 
option -nodefaultlibs does include the startfiles. And the option -nostdlib 
does not include the startfiles.

So when I replace -nodefaultlibs with -nostdlib in the above command line 
I'm getting a different undefined reference:
ertr000001.o:(.rdata+0x0): undefined reference to 
`_pei386_runtime_relocator'

My questions are:
Do you think the gcc supplied startfiles are interoperable with LLVM libc++?
Can you think of a way to get my example to link correctly?

Best regards,
Maarten Verhage 


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

Reply via email to