Linker error when using static members

后端 未结 2 1628
滥情空心
滥情空心 2020-12-11 22:06

I\'m using Qt 4.7 and Cmake 2.8.3 with g++ 4.2.1 on Mac OS X.

I\'m getting a bizarre linker error when using static or global variables in one of my files. Here\'s t

2条回答
  •  春和景丽
    2020-12-11 22:24

    You need to define the static variable in cpp file and not in header file. If you define it in header file, every cpp file which includes this header will get its own copy hence linker complains about duplicate symbols.

提交回复
热议问题