gcc中__attribute__ ((constructor(101)))做成.a库成功链接
1.cpp:------------------------------------------------
#include
int test() __attribute__ ((constructor(101)));
int test()
{
}
test.cpp
#include
int main()
{
}
g++ -c 1.cpp
ar -rcs libanti.a 1.o
g++ test.cpp -Wl,--whole-archive libanti.a -Wl,--no-whole-archive -o main