[CMake] Newbie question: Static linking

Sanatan Rai sanatan at gmail.com
Mon May 23 09:25:42 EDT 2011


On 23 May 2011 13:38, Michael Wild <themiwi at gmail.com> wrote:
> On 05/23/2011 02:20 PM, Sanatan Rai wrote:
>> On 23 May 2011 12:54, Michael Jackson <mike.jackson at bluequartz.net> wrote:
>>> You might want to take a look at the Factory design pattern.
>>>
>>
>> That's exactly what I use...
>>
>> --Sanatan
>
> Yes, but you are registering the concrete factories implicitly instead
> of explicitly, which is causing you the trouble you experience.
>
> Better have your user provide a function registering his/her classes
> explicitly.

I guess this is getting to be off topic, but indeed the
anonymous namespace trick is supposed to do exactly that.

I am not trying to be difficult here---just that it is not clear to me
that the solution to this problem is that straightforward.

When all the code files are linked in one monolithic bloc, everything
works correctly. It is when one starts dividing them into individual
libraries that this problem occurs. I haven't seen a solution to this
problem either in books or via google.

--Sanatan


More information about the CMake mailing list