在 2024-10-08 18:43, Marius Mikučionis 写道:
Hi, I am using g++-14 from mingw64 from MSYS2 on Windows. I am trying to discover the location of C and C++ standard libraries by using command `gcc -print-file-name=libstdc++-6.dll`, but it just prints the library filename without an absolute path.
Did it work before?`-print-file-name=` is supposed to print a file for linking, but DLLs aren't meant to be linked, so it should not give any sensible results. (The fact that DLLs can be linked directly doesn't justify that.)
Instead, this is likely to produce a path to the import library: g++ -print-file-name=libstdc++.dll.a
GCC-13 used to print the absolute path, but GCC-14/Mingw does not anymore. Native GCC-14 on Linux (Fedora, Ubuntu, Debian) prints the absolute path, but not the GCC-14/Mingw build.
On Linux, SO files belong in the `lib` directory, but on Windows DLL files belong in `bin`. And that's the difference: If you copy libstdc++-6.dll into `lib` then it may produce something meaningful.
*Is there an alternative way to figure out the location of the libraries used by GCC-14/Mingw?* Within MSYS2 ldd is actually helpful in displaying what the library loading will load, but it is not available when cross-compiling on Fedora which ships mingw-gcc-14 (Ubuntu and Debian ship gcc-13/mingw, which does not have this problem). On Linux I use objcdump to inspect the dependencies, but it does not print the absolute path.
On Debian/Ubuntu/Mint, this DLL is installed to `/usr/lib/gcc/x86_64-w64-mingw32/13-win32/libstdc++-6.dll` for GCC 13 the win32 thread model (there is another one for the posix thread model), but it is not a standard DLL directory. If you attempt to launch such a program with Wine, it will fail to start.
You can get the file name (basename) of a DLL with `dlltool -I`: $ x86_64-w64-mingw32-g++ -print-file-name=libstdc++.dll.a /usr/lib/gcc/x86_64-w64-mingw32/13-win32/libstdc++.dll.a $ x86_64-w64-mingw32-dlltool -I /usr/lib/gcc/x86_64-w64-mingw32/13-win32/libstdc++.dll.a libstdc++-6.dllHowever I don't think there is a reliable way to get absolute paths to these DLLs. Perhaps you will have to hard-code these rules: The DLL may be in the same directory as the import library, or `../bin/` relative from the import directory.
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public