libc

Runtime Library mis-matches and VC++ - Oh, the misery!

烂漫一生 提交于 2019-12-03 02:23:13
It seems that all my adult life I've been tormented by the VC++ linker complaining or balking because various libraries do not agree on which version of the Runtime library to use. I'm never in the mood to master that dismal subject. So I just try to mess with it until it works. The error messages are never useful. Neither is the Microsoft documentation on the subject - not to me at least. Sometimes it does not find functions - because the name-mangling is not what was expected? Sometimes it refuses to mix-and-match. Other times it just says, "LINK : warning LNK4098: defaultlib 'LIBCMTD'

What does “f” stand for in C standard library function names?

别来无恙 提交于 2019-12-03 01:49:21
What does f stand for in the name of C standard library functions? I have noticed that a lot of functions have an f in their name, and this does not really make sense to me. For example: fgets , fopen , printf , scanf , sqrtf and so on. Your question in general is too general but I can explain a few examples. f gets , f open , f close , … — The ”f“ stands for “file”. These functions accept or return a FILE * pointer as opposed to a file number as the POSIX functions do. print f , scan f , … — The ”f“ stands for “formatted”. These functions accept a format string. f print f , f scan f — This is

Why is argv parameter to execvp not const?

不问归期 提交于 2019-12-03 01:15:50
execvp is defined thus: int execvp(const char *file, char *const argv[]); Which precludes code such as this from being used: const char* argv[] = {"/bin/my", "command", "here", NULL}; execvp(argv[0], argv); Was this an accidental omission? Is it safe to const_cast around this? Or do some execvp implementations actually scribble on that memory? The POSIX spec says ( http://pubs.opengroup.org/onlinepubs/009604499/functions/exec.html ): The argv[] and envp[] arrays of pointers and the strings to which those arrays point shall not be modified by a call to one of the exec functions, except as a

Overlapping pages with mmap (MAP_FIXED)

扶醉桌前 提交于 2019-12-02 23:23:36
Due to some obscure reasons which are not relevant for this question, I need to resort to use MAP_FIXED in order to obtain a page close to where the text section of libc lives in memory. Before reading mmap(2) (which I should had done in the first place), I was expecting to get an error if I called mmap with MAP_FIXED and a base address overlapping an already-mapped area. However that is not the case. For instance, here is part of /proc/maps for certain process 7ffff7299000-7ffff744c000 r-xp 00000000 08:05 654098 /lib/x86_64-linux-gnu/libc-2.15.so Which, after making the following mmap call ..

Where is ptrdiff_t defined in C?

一笑奈何 提交于 2019-12-02 23:15:37
Where is ptrdiff_t defined in C? If non-trivial, how can I make this type visible from GCC on Linux? It's defined in stddef.h . That header defines the integral types size_t , ptrdiff_t , and wchar_t , the functional macro offsetof , and the constant macro NULL . It is defined by the POSIX standard: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html Where the type is exactly may be implemetation-specific, but interface is stddef.h Since @Good Person said this wasn't specific to Linux, in Microsoft Visual Studio, ptrdiff_t is defined in: C:\Program Files (x86)\Microsoft

Undefined reference to `clock_gettime` although `-lrt` is given

巧了我就是萌 提交于 2019-12-02 21:11:04
I've give -lrt as the last linker flag to the compiler. But still getting this error. arif@khost:~/sak/sak.exosip$ gcc eXo_init.c -I/opt/osip2/include -I/opt/exosip/include -L/opt/osip2/lib -L/opt/exosip/lib -leXosip2 -losipparser2 -losip2 -lrt /opt/osip2/lib/libosip2.so: undefined reference to `clock_gettime' collect2: ld returned 1 exit status The man page says : NAME clock_getres, clock_gettime, clock_settime - clock and time functions SYNOPSIS #include <time.h> int clock_getres(clockid_t clk_id, struct timespec *res); int clock_gettime(clockid_t clk_id, struct timespec *tp); int clock

memccpy return lower memory address than the src starting address

有些话、适合烂在心里 提交于 2019-12-02 20:29:41
问题 I've got a school project where I have to recode the memccpy() function. I use 2 programs to check if my code works properly. The first is a small program with only a main. The second program is developped by another student (can be found here, if you want to see it) With my program, there is no problem, both my memccpy and the original function return the right pointer on the right character from the dest pointer. But with the second program, the original function return a lower pointer

Why does loading the libc shared library have “'LibraryLoader' object is not callable” error?

自闭症网瘾萝莉.ら 提交于 2019-12-02 12:35:36
问题 From https://en.wikipedia.org/wiki/Foreign_function_interface the ctypes module can load C functions from shared libraries/DLLs on-the-fly and translate simple data types automatically between Python and C semantics as follows: import ctypes libc = ctypes.CDLL( '/lib/libc.so.6' ) # under Linux/Unix t = libc.time(None) # equivalent C code: t = time(NULL) print t On Lubuntu 18.04 $ whereis libc libc: /usr/lib/x86_64-linux-gnu/libc.a /usr/lib/x86_64-linux-gnu/libc.so /usr/share/man/man7/libc.7

Solaris 11 / Illumos / OmniOS: Which package has /usr/include/sys/types.h?

霸气de小男生 提交于 2019-12-02 09:44:12
问题 The Ubuntu equivalent would be libc6-dev , but I can't seem to find it for Solaris? How can I get types.h and related files for building packages on Solaris or Illumos? 回答1: You need the system/header package. I found this via http://pkg.oracle.com/solaris/release/en/search.shtml?token=types.h&action=Search 回答2: Assuming you use IPS 'pkg search 'types.h'' The Oracle Solaris 11 Cheat Sheet for Image Packaging System could be useful, too. 来源: https://stackoverflow.com/questions/8773535/solaris

Relink a shared library to a different version of libc

随声附和 提交于 2019-12-02 04:48:04
问题 I have a linux shared library (.so) compiled with a specific version of libc (GLIBC2.4) and I need to use it on a system with different version of libc. I do not have sources for the library in question so I cannot recompile for the new system. Is it somehow possible to change the dependencies in that library to a different libc? 回答1: If you need the .so on a system with an older glibc, you would need the source code and recompile/relink it with the older glibc. The alternative is to install