Hi,
I already posted this question on fr.comp.lang.c++ without response.
I am experiencing some trouble in the instatiation of global variables
in recent ubuntu versions. I don't know if this question is directly
related to g++ or the linker as the following example works fine on
debian squeeze with gcc 4.7 and fails on the two last versions of
ubuntu. If the question is not relevant in this mailing list, please
tell me where I shall redirect it.
I now show a simple code snipset to illustrate the trouble.
Consider the following code in file A.cxx :
#include<iostream>
struct A
{
A(){
std::cout << "A" << std::endl;
}
};
A a; // global variable !!
This file is used to produce a shared library libA.so :
g++ --shared -fPIC A.cxx -o libA.so
Consider now an empty main in file test.cxx:
#include<cstdlib>
int main(void){return EXIT_SUCCESS;}
This file is turned into an executable which is linked with the previous
library:
g++ test.cxx -o test -L. -lA
on debian squeeze (an all previous versions of linux) : this prints "A"
du to the constructor of the global variable
on ubuntu linux precise pangolin, nothing is printed !
This is really annoying and none of __attribute__ I tried solved the
problem. This is also strange to see that if the libA is dlopened, the
program displays the expected message ("A")...
Could anyone tell me :
1) what has changed
2) if the previous behaviour can be retrieved
Thanks for any help
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
https://lists.gnu.org/mailman/listinfo/help-gplusplus