[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Problems linking lib that uses the constructor __attribute



Hi,

On Thursday 01 July 2010, Vincent Rivière wrote:
> This is because of the rule:
> "A .o file located inside a static library will be linked only if some
> other previously linked object require it".
>
> However, the .o file contains the special __attribute__((constructor)) to
> auto register itself, but only when it is already linked :-(
>
> So the only solution is to force the linkage of the .o file containing
> the SDL frontend:
>
> - by adding a reference to any public symbol defined in the file
> containing the __attribute__((constructor)). This may be a reference to
> sdl_register_frontend() (like you posted in your other message) or a
> reference to another public function or variable defined in the same
> file.
>
> - or :
> > There is an trick to make it compile correctly: use the
> > -Wl,--whole-archive flag, but Vincent told me to not use this flag ...
> > :)

What if the function is moved to an *.o file that will be always linked
to the application, like the one containing main()?



	- Eero