glibc

Static Class Variables in Dynamic Library and Main Program [duplicate]

五迷三道 提交于 2019-11-30 22:38:08
This question already has an answer here: Main Program and Shared Library initializes same static variable in __static_initialization_and_destruction_0 1 answer I am working on a project that has a class 'A' that contains a static stl container class. This class is included in both my main program and a .so file. The class uses the default(implicit, not declared) constructor/destructor. The main program loads the .so file using dlopen() and in its destructor, calls dlclose(). The program crashes after main exits when glibc calls the destructor for the static class member variable. The problem

CentOS7静默安装Oracle11gR2

落爺英雄遲暮 提交于 2019-11-30 20:53:08
使用最小化的设定安装完CentOS7后,进入安装Oracle步骤前,需要安装几个工具。具体步骤: yum -y install vim --vim编辑器 yum -y install unzip --zip文件的解压工具 yum -y install lrzsz --上传下载工具 yum -y update --升级所有包,系统版本和内核,改变软件设置和系统设置 注:使用yum安装前,先保证系统可访问互联网。如果在系统无法访问的情况下,可以配置yum资源中心为镜像文件或者下载rpm包进行安装。 完成工具的安装之后,准备进入Oracle的安装过程。 第一步: 安装必须的依赖包 yum -y install gcc yum -y install gcc-c++ yum -y install make yum -y install binutils yum -y install compat-libstdc++-33 yum -y install elfutils-libelf yum -y install elfutils-libelf-devel yum -y install elfutils-libelf-devel-static yum -y install glibc yum -y install glibc-common yum -y install glibc-devel

Why is _init from glibc's csu/init-first.c called before _start even if _start is the ELF entry point?

天大地大妈咪最大 提交于 2019-11-30 20:12:38
I first noticed it while playing with GDB's rbreak . , and then made a minimal example: (gdb) file hello_world.out Reading symbols from hello_world.out...done. (gdb) b _init Breakpoint 1 at 0x4003e0 (gdb) b _start Breakpoint 2 at 0x400440 (gdb) run Starting program: /home/ciro/bak/git/cpp/cheat/gdb/hello_world.out Breakpoint 1, _init (argc=1, argv=0x7fffffffd698, envp=0x7fffffffd6a8) at ../csu/init-first.c:52 52 ../csu/init-first.c: No such file or directory. (gdb) continue Continuing. Breakpoint 2, 0x0000000000400440 in _start () (gdb) continue Continuing. Breakpoint 1, 0x00000000004003e0 in

Static Class Variables in Dynamic Library and Main Program [duplicate]

末鹿安然 提交于 2019-11-30 18:00:24
问题 This question already has an answer here : Main Program and Shared Library initializes same static variable in __static_initialization_and_destruction_0 (1 answer) Closed last year . I am working on a project that has a class 'A' that contains a static stl container class. This class is included in both my main program and a .so file. The class uses the default(implicit, not declared) constructor/destructor. The main program loads the .so file using dlopen() and in its destructor, calls

Is there an auto-resizing array/dynamic array implementation for C that comes with glibc?

折月煮酒 提交于 2019-11-30 17:27:18
Is there a dynamic array implementation in glibc or any of the standard Linux libraries for C? I want to be able to add to a list without worrying about its size. I know std::vector exists for C++, but I need the C equivalent. I guess you are thinking of realloc . But its better to wrap a list in a structure to keep track of its current length Example API struct s_dynamic_array { int allocated; /* keep track of allocated size */ int usedLength; /* keep track of usage */ int *array; /* dynamicaly grown with realloc */ }; typedef struct s_dynamic_array s_dynamic_array; s_dynamic_array *new

Since the Standard C committee did not standardize a simple replacement for gets(), what should it be?

梦想的初衷 提交于 2019-11-30 17:13:15
The gets function was first deprecated in C99 and finally removed in C11. Yet there is no direct replacement for it in the C library. fgets() is not a drop-in replacement because it does not strip the final '\n' , which may be absent at the end of file. Many programmers get it wrong too. There is a one-liner to remove the linefeed: buf[strcspn(buf, "\n")] = '\0'; , but it is non-trivial and often calls for an explanation. It may be inefficient as well. This is counter-productive. Many beginners still use gets() because their teachers are lame or their tutorials obsolete. Microsoft proposed

Can I use glibc under windows?

↘锁芯ラ 提交于 2019-11-30 17:09:58
问题 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? 回答1: 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

Is there an auto-resizing array/dynamic array implementation for C that comes with glibc?

时光怂恿深爱的人放手 提交于 2019-11-30 16:38:52
问题 Is there a dynamic array implementation in glibc or any of the standard Linux libraries for C? I want to be able to add to a list without worrying about its size. I know std::vector exists for C++, but I need the C equivalent. 回答1: I guess you are thinking of realloc. But its better to wrap a list in a structure to keep track of its current length Example API struct s_dynamic_array { int allocated; /* keep track of allocated size */ int usedLength; /* keep track of usage */ int *array; /*

【Linux 初学】Mongdb、数据库Mysql安装(四)

旧城冷巷雨未停 提交于 2019-11-30 12:21:44
一、linux下mongdb的安装 1.下载安装包 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.0.tgz 下载完成后解压缩压缩包 tar -zxvf mongodb - linux -x86_ 64 -2.0.4 2. 安装准备 将mongodb移动到/usr/local/mongodb文件夹 mv bin/ mongodb - linux -x86_ 64 -2.0.4/* mongodb/ 创建数据库文件夹与日志文件(这里是logs文件,非文件夹) mkdir /usr/local/mongodb/data touch /usr/local/mongodb/logs.log 3. 设置开机自启动(非必要步骤) 将mongodb启动项目追加入rc.local保证mongodb在服务器开机时启动 echo "/usr/local/server/bin/mongod --dbpath=/usr/local/mongodb/data –logpath=/usr/local/mongodb/logs –logappend --auth –port=27017" >> /etc/rc.local 4. 启动mongodb cd到mongodb目录下的bin文件夹启动mongodb /

Linux系统glibc库版本信息查看

陌路散爱 提交于 2019-11-30 12:21:29
有时我们经常需要查看当前系统的glibc版本,可以这样查看: /lib/libc.so.6 有时:/lib/x86-64-linux/libc.so.6 把这个文件当命令执行一下 为什么这个库可以直接run呢? 原来在libc的代码中有一点小手脚: Makerules:586:LDFLAGS-c.so += -e __libc_main csu/version.c:71:__libc_main (void) void __libc_main (void) { __libc_print_version (); _exit (0); } 或者: 因为ldd命令也是glibc提供的,所以也能查看 ldd --version glibc是什么,以及与gcc的关系? glibc是gnu发布的libc库,也即c运行库。glibc是linux 系统中最底层的api(应用程序开发接口),几乎其它任何的运行库都会倚赖于glibc。glibc除了封装linux操作系统所提供的系统服务外,它本 身也提供了许多其它一些必要功能服务的实现,主要的如下: (1)string,字符串处理 (2)signal,信号处理 (3)dlfcn,管理共享库的动态加载 (4)direct,文件目录操作 (5)elf,共享库的动态加载器,也即interpreter (6)iconv,不同字符集的编码转换 (7)inet