How to specify non-default shared-library path in GCC Linux? Getting “error while loading shared libraries” when running

There are two ways to achieve that: Use -rpath linker option: gcc XXX.c -o xxx.out -L$HOME/.usr/lib -lXX -Wl,-rpath=/home/user/.usr/lib Use LD_LIBRARY_PATH environment variable – put this line in your ~/.bashrc file: export LD_LIBRARY_PATH=/home/user/.usr/lib This will work even for a pre-generated binaries, so you can for example download some packages from the debian.org, unpack the binaries and … Read more

How to use addr2line in Android

Let’s say that logcat show you the following crash log (this is from one of my projects): I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** I/DEBUG ( 31): Build fingerprint: ‘generic/sdk/generic:2.3/GRH55/79397:eng/test-keys’ I/DEBUG ( 31): pid: 378, tid: 386 >>> com.example.gltest <<< I/DEBUG ( 31): … Read more

What exactly does `-rdynamic` do and when exactly is it needed?

Here is a simple example project to illustrate the use of -rdynamic. bar.c extern void foo(void); void bar(void) { foo(); } main.c #include <dlfcn.h> #include <stdio.h> #include <stdlib.h> void foo(void) { puts(“Hello world”); } int main(void) { void * dlh = dlopen(“./libbar.so”, RTLD_NOW); if (!dlh) { fprintf(stderr, “%s\n”, dlerror()); exit(EXIT_FAILURE); } void (*bar)(void) = dlsym(dlh,”bar”); … Read more

“relocation R_X86_64_32S against ” linking Error

Assuming you are generating a shared library, most probably what happens is that the variant of liblog4cplus.a you are using wasn’t compiled with -fPIC. In linux, you can confirm this by extracting the object files from the static library and checking their relocations: ar -x liblog4cplus.a readelf –relocs fileappender.o | egrep ‘(GOT|PLT|JU?MP_SLOT)’ If the output … Read more

How do you find what version of libstdc++ library is installed on your linux machine?

To find which library is being used you could run $ /sbin/ldconfig -p | grep stdc++ libstdc++.so.6 (libc6) => /usr/lib/libstdc++.so.6 The list of compatible versions for libstdc++ version 3.4.0 and above is provided by $ strings /usr/lib/libstdc++.so.6 | grep LIBCXX GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 … For earlier versions the symbol GLIBCPP is defined. The date stamp … Read more

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