Is it (or would it) be possible to use glibc under windows (as a replacement of msvcrt)? I know this is a stupid question, and answers like cygwin will pop up, but I am really asking: is it possible to link to glibc on windows and use all library functions like with msvcrt?
2 Answers
glibc used to work on different *nixes once , these days glibc is quite Linux specific. It will certainly not work on windows.
-
And thus we should rewrite our open-sourced code on each platform and surround it by lot of preprocessor's #ifdefs... Cross-platform with two different worlds is myth: Windows on one side and Linux, BSD, OS X, iOS etc. (them all cross-platform, besides!) - on another side. It is war of OSes which results in lot of poor-quality code... Jul 9, 2014 at 23:31
-
@BrianHaak your claims have little to do with glibc. Glibc is just one of many libs (granted though, one of most popular) implementing standard c functions (and a bit of other churn). As far as you're using standard c functions, you don't need platform-dependent #ifdefs. Your example from the other comment here is using an extension of GCC, and notably α) have nothing to do with libraries, and β) such a code is generally frowned upon, unless author have really compelling reasons.– Hi-AngelJul 7, 2017 at 20:56
A possible workaround could exist: if someone combines http://0xef.wordpress.com/2012/11/17/emulate-linux-system-calls-on-windows/ with http://www.musl-libc.org/ and compiles source code with gcc against musl libc instead of glibc. So, I can't understand why nobody writes a such glibc analog for Windows. :-(
-
Thanks for the interesting reference. It seems like quite a hack to rely on handling the exceptions, but hey, it might just work well enough... Pretty neat nonetheles!– rubenvbJul 10, 2014 at 6:58
-
Actually, I need to cross-compile open source libraries which developed for Linux only. They use no system references but modern GCC's C and C++ and its STANDARD library calls - something that implemented by GLibC/musl-libc/newlib. I have disappointed in Visual Studio C compiler. I would like to compile code with GCC on Linux/OS X then move OBJECT FILES to Windows and link them with Windows-platform specific application code, which compiled with MSVC. So, THE ONLY PROBLEM I HAVE - on Windows, there is NO GCC-compatible STANDARD C LIBRARY!!! Jul 10, 2014 at 8:16
-
Otherwise, how to compile this on Windows:
typedef uint8_t v16 __attribute__ ((vector_size (16)));
and so on, QFS Reed-Solomon fragment on GitHub ? Jul 10, 2014 at 8:21 -
2"Performance tests on the Internet"... Yeah, that's great. Test yourself. And don't compare apples to oranges: comparing binary code execution cross-OS is near to pointless: better would be to compare MSVC vs MinGW-w64 GCC, and I bet you MinGW-w64 GCC is quite fast
;-)
– rubenvbJul 10, 2014 at 9:36 -
1