Constructors in Static Libs -> Not called for global obje

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi
I have recently splitted my application into several static libs to reduce compiletime.
Now i have strange problems.

It seems that objects declared within a static lib that are not initialised by their constructors.
A while(1) within a constructor confirms my statement. The program does not hang.
WHY.

Addiditonal, AVR32 Studio 2.6 spends a great amount of time to determine that the project does not need be be rebuilt. It really sucks.

Every time i build my project it checks all other projects (the static libs) within the workspace. That takes A LOT of TIME. (30-45sec hat was nearly the time of the whole original project to build (1min))
Waht to do :-/

Last Edited: Wed. Nov 3, 2010 - 05:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build project only. Right click on the project element in Project Explorer and select Build project. Or from Project menu select Build project.

The Ctrl+B keyboard shortcut is by default tied to Build All.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes of course. Shortcuts are redefined now. But trying to start the debugger still checks ALL the projects. It spends a lot of time compiling a "spec.cpp" inside the .metadata folder. For every project! :-( Just to find out that the binary does not need to be refreshed.
Absolutely frustrating. Using an IDe that waste my time for doing nothing. Grrrrrr. :-(

But the bigger problem is still there.. why no constructors are called for global objects within a static lib.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for doubleposting, but i have important news:
i have copied some global instances (declared with "extern" within the headers) into some Cpp-files of the main project (non static lib project)
Then the constructors are called.
Verry interesting.
What is the reason of this behavior.. it cannot be right, that constructors of global objects in a static lib are not called.

Could this be a problem of the linker file? :-O

I really need help :-(

Edit:
I have tried the --whole-archive flag. It now causes many errors since now a lot of doubled functions are linked. This is also not the behavior i want to have.

Maybe it is an option to link the .o Files instead of the lib itself. This would invcrease linkingtime, but it should work.
But: HOW to link the .o