How to find the glibc version for mingw32-gcc-win32 compiler? - version

How to find the glibc version for x86_64-w64-mingw32-gcc-win32 compiler ?

How to find the glibc version for x86_64-w64-mingw32-gcc-win32 compiler ?
GLIBC does not support Win32, so the answer to "which GLIBC version" is: none.
Instead, a completely different libc is used.
See also http://xyproblem.info

Related

Cygwin doesn't define __STDC_IEC_559__

I was curious if this is intentional. I found that traditionally __STDC_IEC_559__ is defined in glibc and then used by gcc. Cygwin doesn't use glibc however, and I was wondering if __STDC_IEC_559__ isn't defined by newlib for whatever reason or if it is merely a problem on my end.
I understand that all compilers/libraries do not define __STDC_IEC_559__ as they are not all compliant with the standard, I am just trying to figure out why the libraries used by cygwin specifically are not.

In what library is strcat_s?

I tried including string.h and stdlib.h, but still get undefined reference compile errors.
This leads me to conclude that it is in a different library that I didn't include. Where is it?
I am using gcc compiler - the code is written in Windows, but is going to be compiled and run on a unix server.
strcat_s can be found in string.h as of C 2011. Generally speaking, only microsoft has implemented these alternative functions.
There's an implementation in slibc.
It is present in string.h on windows platform
You can also refer this cppreference
Defined in header <string.h>
You can better use strcat if you are working on UNIX platform.
It seems it is part of C11 standard:
http://en.cppreference.com/w/c/string/byte/strcat
https://www.securecoding.cert.org/confluence/display/c/API02-C.+Functions+that+read+or+write+to+or+from+an+array+should+take+an+argument+to+specify+the+source+or+target+size
Honestly, I am not very well-versed with when it comes to standards and I can very well be wrong >.<

gcc: Reduce libc required version

I am trying to run a newly compiled binary on some oldish 32bits RedHat distribution.
The binary is compiled C (not++) on a CentOS 32bits VM running libc v2.12.
RedHat complains about libc version: error while loading shared libraries: requires glibc 2.5 or later dynamic linker
Since my program is rather simplistic, It is most likely not using anything new from libc.
Is there a way to reduce libc version requirement
An untested possible solution
What is "error while loading shared libraries: requires glibc 2.5 or later dynamic linker"?
The cause of this error is the dynamic binary (or one of its dependent
shared libraries) you want to run only has .gnu.hash section, but the
ld.so on the target machine is too old to recognize .gnu.hash; it only
recognizes the old-school .hash section.
This usually happens when the dynamic binary in question is built
using newer version of GCC. The solution is to recompile the code with
either -static compiler command-line option (to create a static
binary), or the following option:
-Wl,--hash-style=both
This tells the link editor ld to create both .gnu.hash and .hash
sections.
According to ld documentation here, the old-school .hash section
is the default, but the compiler can override it. For example, the GCC
(which is version 4.1.2) on RHEL (Red Hat Enterprise Linux) Server
release 5.5 has this line:
$ gcc -dumpspecs
....
*link:
%{!static:--eh-frame-hdr} %{!m32:-m elf_x86_64} %{m32:-m elf_i386} --hash-style=gnu %{shared:-shared} ....
^^^^^^^^^^^^^^^^
...
For more information, see here.
I already had the same problem, trying to compile a little tool (I wrote) for an old machine for which I had not compiler. I compiled it on an up to date machine, and the binary required at least GLIBC 2.14 in order to run.
By making a dump of the binary (with xxd), I found this :
....
5f64 736f 5f68 616e 646c 6500 6d65 6d63 _dso_handle.memc
7079 4040 474c 4942 435f 322e 3134 005f py##GLIBC_2.14._
....
So I replaced the memcpy calls in my code by a call to an home-made memcpy, and the dependency with the glibc 2.14 magically disappeared.
I'm sorry I can't really explain why it worked, or I can't explain why it didn't work before the modification.
Hope it helped !
Ok then, trying to find some balance between elegance and brute force, I downloaded a VM matching the target kernel version, hence fixing library issues.
The whole thing (download + yum install gcc) took less than 30 minutes.
References: Virtual machines, Kernel Version Mapping Table

mrand not in mingw?

I use dev c++ for my c projects,because it's simple for me.I installed it with the mingw extension.Well,I included stdlib.h and made a call to mrand which according to manpages belongs to that header but I got a linker error.I looked in mingw's headers and found no declaration for mrand although the glibc has one in stdlib.Am I missing something?I thought mingw and gcc were the same.If they are different I suppose that there isn't a way to get gcc's full power.Right?Thank you.
mrand is not part of the standard C library, nor is it present in standard Linux manpages. Whatever compiler you previously used may have had it as a proprietary extension, but since you haven't mentioned which (it's not GCC or MSVC, at least), I can't tell what mrand is supposed to do, and so it's hard to suggest an alternative function to use.
Note that glibc does offer a mrand48(). Since this is a POSIX function, not a standard C function, it may or may not be present in other C libraries - but note that this is a function of the C library (glibc), not the compiler (gcc/mingw).

Where can I find the implementation of "time.h"?

Where can I find the implementation of time.h in the C Standard Library, i.e time.c?
I tried with Google Code Search time.c
Is the implementation in the Linux kernel?
time.h is a header from the C standard library.
You will find implementations of the various functions this header provides in the c library implementation of your system.
For instance, the implementation for the difftime function in the libc used for NetBSD can be found in src/lib/libc/time/difftime.c.
For GNU libc, see http://sourceware.org/git/?p=glibc.git;a=tree;f=time;h=c950c5d4dd90541e8f3c7e1649fcde4aead989bb;hb=master
You can find an implementation in the GNU libc library. There isn't a single time.c file. Each function (to a first approximation) lives in its own compilation unit.
Are you actually looking for the implementation of C in the standard library?
Each compiler and OS typically comes with their own implementation (just the headers are relatively standard).
You can see instructions on downloading the sources for GNU C here:
http://www.gnu.org/software/libc/resources.html
time.h is a C standard header, so it describes functions from the C standard library with which it came. For instance, GNU libc

Resources