Description of the problem:

I create module.cpp; which has a function labeled __attribute__((constructor)).

  If I link module.o directly; the function gets called.

If I make module.o into libmodule.a and then link libmodule.a, the function does not get called.

  Attached is the test case:

Thanks
--TongKe
default:
        g++ module.cpp -c
        ar cq libmodule.a module.o
        g++ test.cpp module.o -o from-object
        g++ test.cpp libmodule.a -o from-lib
#include <iostream>

using namespace std;

void foo() __attribute__((constructor));

void foo()
{
  cout << "Yay life is good." << endl;
}
int main()
{
  return 0;
}

Reply via email to