top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the lowest priority for init_priority attribute that I can use to still have libstdc++ initialize itself ...

+2 votes

I want to use the init_priority(prio) attribute

to initialize stuff in my library early so that users of the library can use the library during their own static objects construction. However, my library uses standard C++ library facilities like std::string,
std::vector, etc. The question is:

What is the lowest priority for init_priority attribute that I can use to still have libstdc++ initialize itself before my library is initialized?

posted Aug 17, 2014 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

I am building a shared library which will be distributed to clients in binary form only. I am attempting to make the same binary run on as many Linux variants as possible, and so when I build it I specify the
options -shared and -fPIC. As part of the effort of making the library as independent as possible, I also link both the C and C++ standard libraries statically into the final shared library. I want to do this because I use
C++11 features internally, and I don't want to force the users of my library to have a C++11 compiler handy.

When doing this, do I need to build libstdc++ and libgcc from source with -fPIC as well? Or is it okay to link with the static versions of these libraries that are provided in my Ubuntu 13.04 gcc package?

To clarify, no exceptions are thrown over library boundaries; all exceptions used internally in the library are caught and processed behind the scenes. None of them ever reach the client code, as the client communicates with the library using a plain C interface.

My exact build flags are as follows:

g++ -fvisibility=hidden -fvisibility-inlines-hidden -static-libstdc++ -static-libgcc -s -DNDEBUG -std=c++11 -Wall -shared -fPIC -o test.cpp -lpthread -O2

+3 votes

Is there a way to append a list of files as an executable to the file itself such that the file is still executable?

For example let's say I have 2 files file1 and file2. How might I append the the files in a way to the binary. Again this is a simple example, I would like to have a cross Operating System way to extract Unix and Windows functions. Cross operating system way to append zips (or tar.gz) to a file only to extract it later.

The following illustrates how the files might be extracted and or created.

create ./a.exe ./output.exe file1 file2

extract output.exe