[mythtv] I'm working on UNICABLE improvment - help needed

Jean-Yves Avenard jyavenard at gmail.com
Mon Aug 26 15:37:15 UTC 2013


On 26 August 2013 21:06, warpme <warpme at o2.pl> wrote:
> Hi,
> Forgive me maybe lame question, but c++ isn't thing I know enough.
>
> I want to share&use global variable between all instances of dvbchannel
> objects.
> My idea was to declare this variable as static in dvbchannel.h.
>
> class DVBChannel : public DTVChannel
> {
>   public:
>     static QDateTime  last_tuning;
>
> It compiles, but unfortunately linker returns:
> ../../libs/libmythtv/libmythtv-0.27.so: undefined reference to
> `DVBChannel::last_tuning'
>
> So what is best way to declare global, shared variable used by all instances
> of dvbchannel ?

if you define a static variable, it can't be just defined in the header.
so in your cpp add something like:

QDataTime DVBChannel::last_tuning;


More information about the mythtv-dev mailing list