Why do I have to define LD_LIBRARY_PATH with an export every time I run my application?

You should avoid setting LD_LIBRARY_PATH in your .bashrc. See “Why LD_LIBRARY_PATH is bad” for more information. Use the linker option -rpath while linking so that the dynamic linker knows where to find libsync.so during runtime. gcc … -Wl,-rpath /path/to/library -L/path/to/library -lsync -o sync_test EDIT: Another way would be to use a wrapper like this #!/bin/bash … Read more

Where is linux-vdso.so.1 present on the file system

It’s a virtual shared object that doesn’t have any physical file on the disk; it’s a part of the kernel that’s exported into every program’s address space when it’s loaded. It’s main purpose to make more efficient to call certain system calls (which would otherwise incur performance issues like this). The most prominent being gettimeofday(2). … Read more

Elegantly call C++ from C

EDIT: Based on discussion in the comment, I should point out that separating things into a C-compatible struct duck and a derived class Duck is probably unnecessary. You can probably safely shovel the implementation into struct duck and eliminate class Duck, thus obviating real(…). But I don’t know C++ well enough (in particular, the way … Read more

Why does GCC create a shared object instead of an executable binary according to file?

What am I doing wrong? Nothing. It sounds like your GCC is configured to build -pie binaries by default. These binaries really are shared libraries (of type ET_DYN), except they run just like a normal executable would. So your should just run your binary, and (if it works) not worry about it. Or you could … Read more

When / How does Linux load shared libraries into address space?

Libraries are loaded by ld.so (dynamic linker or run-time linker aka rtld, ld-linux.so.2 or ld-linux.so.* in case of Linux; part of glibc). It is declared as “interpreter” (INTERP; .interp section) of all dynamic linked ELF binaries. So, when you start program, Linux will start an ld.so (load into memory and jump to its entry point), … Read more

CMake: how to produce binaries “as static as possible”

I did some investigation and although I could not find a satisfying solution to the problem, I did find a half-solution. The problem of static builds boils down to 3 things: Building and linking the project’s internal libraries. Pretty simple, one just has to flip the BUILD_SHARED_LIBS switch OFF. Finding static versions of external libraries. … Read more

Linking two shared libraries with some of the same symbols

There are several ways to solve this: Pass -Bsymbolic or -Bsymbolic-functions to the linker. This has a global effect: every reference to a global symbol (of function type for -Bsymbolic-functions) that can be resolved to a symbol in the library is resolved to that symbol. With this you lose the ability to interpose internal library … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)