glibc

Why does -O to gcc cause “stat” to resolve?

我怕爱的太早我们不能终老 提交于 2019-12-12 13:39:59
问题 Tried to do a search, but didn't find anything. Whenever I try to compile a shared object and the test binary that links to it I get this error: [root@hypervisor test-files]# ./test ./test: symbol lookup error: ./test-files.so: undefined symbol: stat [root@hypervisor test-files]# After playing around with it I found that if I feed -O to gcc during the compile, stat() starts working as expected. I haven't been able to find any indication online as to why -O of all things fixes a problem with

I was perusing glibc when I came across the socket code, can someone explain what is going on?

淺唱寂寞╮ 提交于 2019-12-12 07:51:02
问题 Here is the source I was browsing: glibc source. My particular question arises from this particular set of functions: socket library. For example(most of the functions are set up this way) socket/bind.c 's source is: 19 #include <errno.h> 20 #include <sys/socket.h> 21 22 /* Give the socket FD the local address ADDR (which is LEN bytes long). */ 23 int 24 __bind (fd, addr, len) 25 int fd; 26 __CONST_SOCKADDR_ARG addr; 27 socklen_t len; 28 { 29 __set_errno (ENOSYS); 30 return -1; 31 } 32 33

Linux c++ portable binary issue

♀尐吖头ヾ 提交于 2019-12-12 05:36:51
问题 I try to package my binary and all its shared libraries into an archive. I want user only extracts the archive to make the binary work. The executable is launched via a shell script where I set LD_LIBRARY_PATH to shared library path contained in the archive. On a first time I wanted to make it work on a RHEL 6.7 distribution so I have compiled my binary with this distribution, and when I tested it it works well. The problem is that I have now to make it work on a RHEL 7.2 (and keep RHEL 6.7

Find the interface used by a connected socket

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:59:20
问题 I need to find the specific interface which is used by a socket, so that I can keep stats for it, using the sysfs files ( /sys/class/net/<IF>/statistics/etc ). I've tried two different approaches in the test code below, but both fail. The first one connects to a remote server, and uses ioctl with SIOCGIFNAME , but this fails with 'no such device'. The second one instead uses getsockopt with SO_BINDTODEVICE , but this again fails (it sets the name length to 0). Any ideas on why these are

Python CFFI memory management issues

不羁岁月 提交于 2019-12-12 02:52:13
问题 I am programming on Ubuntu, with Python 2.7.3 . I am using CFFI to populate a Python list with values coming from some C code. That list is quite big : around 71 000 characters long when printed. The C code is using many libraries. Hence, the following code is only here for a better understanding of what is happening. datas_list = [] for i in range( 0, x ): c_pDataStructure = ffi.new( "c_DataStructure[]", 1 ) // Create a pointer to the data structure c.SomeCFunction( c_pDataStructure ) //

GLIBC Configuration Error on Solaris

陌路散爱 提交于 2019-12-11 23:31:40
问题 Recently I had to work with glibc to be installed on Solaris OS on the x86 platform. The problem I encountered with was the configuration of the glibc package. I was getting multiple errors.Some of them have been higlighted under: configure:3641: g++ -c -g -O2 conftest.cc >&5 conftest.cc:10:31: error: 'void std::exit(int)' should have been declared inside 'std' configure:3647: $? = 1 To be noted I am using glibc-2.3.5. I could only find out that the glibc ports have not been developed for

g_io_channel + socket = server , still just get one client ? in C language

送分小仙女□ 提交于 2019-12-11 17:37:42
问题 folks, here ma code : #include <glib.h> #include <gio/gio.h> // gio channel #include <sys/socket.h> //socket(); #include <netdb.h> // structure #include <stdio.h> // printf void deal(GIOChannel *in, GIOCondition condition, gpointer data) { struct sockaddr_storage income; int insock = g_io_channel_unix_get_fd(in); socklen_t income_len = sizeof(income); int newsock = accept(insock, (struct sockaddr*)&income, &income_len ); if(newsock == -1) { printf("failure on newsock\n"); } char buff[128];

How to implement something similar to “truncateat”?

て烟熏妆下的殇ゞ 提交于 2019-12-11 14:39:19
问题 While researching this question I came across the fact that in POSIX (and Linux) there simply is not a truncateat system call. Certain system calls like for instance unlink have an equivalent alternative method with an added at suffix at the end of their names, i.e. unlinkat . The difference between those methods is that the variations with the at suffix accept an additional argument, a file descriptor pointing to a directory. Therefore, a relative path passed into unlinkat is not relative to

Errors building glibc: what is wrong with the make/confgure files?

妖精的绣舞 提交于 2019-12-11 13:15:55
问题 I have been trying to build glibc on Clear Linux, with a previous issue discussed here: How do I build into a specified directory using the "prefix" option of configure? Now that I have succeeded in running configure, there seems to be something wrong in the makefile: james@clr ~/Downloads/glibc $ make Makeconfig:42: *** missing separator. Stop. line 42 of Makeconfig: objdir must be defined by the build-directory Makefile. and the nakefile up to the point of error: ifneq (,) This makefile

Glibc - error in ucontext.h, but only with -std=c11

自古美人都是妖i 提交于 2019-12-11 11:33:41
问题 I have this minimal helloworld, extended with an include of ucontext.h : #include <ucontext.h> #include <stdio.h> int main(int argc, char** argv) { printf ("hello world!\n"); return 0; } It compiles without warning with gcc-4.9 ( gcc -c hw.c -Wall ). But if I switch to the c11 standard ( gcc -std=c11 -c hw.c -Wall ), I get the following error: $ gcc -std=c11 -c hw.c -Wall In file included from /usr/include/ucontext.h:26:0, from hw.c:1: /usr/include/x86_64-linux-gnu/sys/ucontext.h:137:5: error