How do I find out what all symbols are exported from a shared object?

Do you have a “shared object” (usually a shared library on AIX), a UNIX shared library, or a Windows DLL? These are all different things, and your question conflates them all 🙁 For an AIX shared object, use dump -Tv /path/to/foo.o. For an ELF shared library, use readelf -Ws –dyn-syms /path/to/libfoo.so, or (if you have … Read more

C++ Dynamic Shared Library on Linux

myclass.h #ifndef __MYCLASS_H__ #define __MYCLASS_H__ class MyClass { public: MyClass(); /* use virtual otherwise linker will try to perform static linkage */ virtual void DoSomething(); private: int x; }; #endif myclass.cc #include “myclass.h” #include <iostream> using namespace std; extern “C” MyClass* create_object() { return new MyClass; } extern “C” void destroy_object( MyClass* object ) { … Read more

How to create a shared library with cmake?

Always specify the minimum required version of cmake cmake_minimum_required(VERSION 3.9) You should declare a project. cmake says it is mandatory and it will define convenient variables PROJECT_NAME, PROJECT_VERSION and PROJECT_DESCRIPTION (this latter variable necessitate cmake 3.9): project(mylib VERSION 1.0.1 DESCRIPTION “mylib description”) Declare a new library target. Please avoid the use of file(GLOB …). This … Read more

What’s the difference between .so, .la and .a library files?

.so files are dynamic libraries. The suffix stands for “shared object”, because all the applications that are linked with the library use the same file, rather than making a copy in the resulting executable. .a files are static libraries. The suffix stands for “archive”, because they’re actually just an archive (made with the ar command … Read more

Linux error while loading shared libraries: cannot open shared object file: No such file or directory

Your library is a dynamic library. You need to tell the operating system where it can locate it at runtime. To do so, we will need to do those easy steps: Find where the library is placed if you don’t know it. sudo find / -name the_name_of_the_file.so Check for the existence of the dynamic library … Read more

When to use dynamic vs. static libraries

Static libraries increase the size of the code in your binary. They’re always loaded and whatever version of the code you compiled with is the version of the code that will run. Dynamic libraries are stored and versioned separately. It’s possible for a version of the dynamic library to be loaded that wasn’t the original … Read more

What are .a and .so files?

Archive libraries (.a) are statically linked i.e when you compile your program with -c option in gcc. So, if there’s any change in library, you need to compile and build your code again. The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your … Read more

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