c++ - How to link an unreferenced variable in a separate cpp file in a static lib? -


here class definition below in "init.cpp":

//-------------------init.cpp----------------- // ... class cnetinit { public: cnetinit(){::wsastartup();} ~cnetinit() {...} };  static cnetinit s_initor; // ... //--------------------------------------------- 

i added cpp static library , , reference lib project, cnetinit's constructor can never executed because no there no reference cpp. how can make work without adding useless reference cpp importing unit?

comment: infact sample, code compiled in xcode , gcc, there standard or non-standard way(like compiler options) this?

you must compile file , link output other object files. way adding variable defined in application.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -