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

How to static link on OS X

In order to link to an archive library (sometimes also called static library), just add it to the link line: gcc main.o … -lfoo … The linker will search for libfoo.dylib, and then libfoo.a, which is all you need. If you have both versions of the library, and want to link with an archive version … Read more

How to apply -fvisibility option to symbols in static libraries?

Simply pass -Wl,–exclude-libs,ALL to gcc This will tell the linker to transform all the symbols in the static libraries to hidden. –exclude-libs also accepts a list of archives (i.e. static library names) for finer granularity on which libraries to hide symbols from. Note: this will only work in systems using GNU binutils (e.g. Linux) or … Read more

ld linker question: the –whole-archive option

There are legitimate uses of –whole-archive when linking executable with static libraries. One example is building C++ code, where global instances “register” themselves in their constructors (warning: untested code): handlers.h typedef void (*handler)(const char *data); void register_handler(const char *protocol, handler h); handler get_handler(const char *protocol); handlers.cc (part of libhandlers.a) typedef map<const char*, handler> HandlerMap; HandlerMap … Read more

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