[SOLVED] Build Optimize 4 & MemoryUsage::get_global_ptr

Just tried to recompile some C code after rebuilding Panda under Panda1.8 (windows) using --optimize 4.

When the Panda1.8 is build with option --optimize 3 everything is fine but under --optimize 4, its seems that some stuff from classes MemoryUsage and PStatClientImpl is left out…

1>Finished searching libraries
1>skybox.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class MemoryUsage * __cdecl MemoryUsage::get_global_ptr(void)" (__imp_?get_global_ptr@MemoryUsage@@CAPAV1@XZ)
1>capsul.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class MemoryUsage * __cdecl MemoryUsage::get_global_ptr(void)" (__imp_?get_global_ptr@MemoryUsage@@CAPAV1@XZ) referenced in function "protected: void __thiscall PointerToBase<class RenderEffect>::reassign(class RenderEffect *)" (?reassign@?$PointerToBase@VRenderEffect@@@@IAEXPAVRenderEffect@@@Z)
1>jctut.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class MemoryUsage * __cdecl MemoryUsage::get_global_ptr(void)" (__imp_?get_global_ptr@MemoryUsage@@CAPAV1@XZ)
1>pantin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class MemoryUsage * __cdecl MemoryUsage::get_global_ptr(void)" (__imp_?get_global_ptr@MemoryUsage@@CAPAV1@XZ)
1>ruler.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class MemoryUsage * __cdecl MemoryUsage::get_global_ptr(void)" (__imp_?get_global_ptr@MemoryUsage@@CAPAV1@XZ)
1>skybox.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_update_type(class ReferenceCount *,class TypeHandle)" (__imp_?ns_update_type@MemoryUsage@@AAEXPAVReferenceCount@@VTypeHandle@@@Z) referenced in function "public: __thiscall PointerTo<class AmbientLight>::~PointerTo<class AmbientLight>(void)" (??1?$PointerTo@VAmbientLight@@@@QAE@XZ)
1>capsul.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_update_type(class ReferenceCount *,class TypeHandle)" (__imp_?ns_update_type@MemoryUsage@@AAEXPAVReferenceCount@@VTypeHandle@@@Z)
1>jctut.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_update_type(class ReferenceCount *,class TypeHandle)" (__imp_?ns_update_type@MemoryUsage@@AAEXPAVReferenceCount@@VTypeHandle@@@Z)
1>pantin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_update_type(class ReferenceCount *,class TypeHandle)" (__imp_?ns_update_type@MemoryUsage@@AAEXPAVReferenceCount@@VTypeHandle@@@Z)
1>ruler.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_update_type(class ReferenceCount *,class TypeHandle)" (__imp_?ns_update_type@MemoryUsage@@AAEXPAVReferenceCount@@VTypeHandle@@@Z)
1>jctut.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class PStatClient * __cdecl PStatClient::get_global_pstats(void)" (__imp_?get_global_pstats@PStatClient@@SAPAV1@XZ) referenced in function _main
1>jctut.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall PStatClient::client_is_connected(void)const " (__imp_?client_is_connected@PStatClient@@QBE_NXZ) referenced in function _main
1>jctut.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall PStatClient::client_disconnect(void)" (__imp_?client_disconnect@PStatClient@@QAEXXZ) referenced in function _main
1>jctut.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_remove_pointer(class ReferenceCount *)" (__imp_?ns_remove_pointer@MemoryUsage@@AAEXPAVReferenceCount@@@Z) referenced in function "public: virtual void * __thiscall PandaNode::`scalar deleting destructor'(unsigned int)" (??_GPandaNode@@UAEPAXI@Z)
1>pantin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: void __thiscall MemoryUsage::ns_remove_pointer(class ReferenceCount *)" (__imp_?ns_remove_pointer@MemoryUsage@@AAEXPAVReferenceCount@@@Z)
1>jctut.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall PStatClientImpl::~PStatClientImpl(void)" (__imp_??1PStatClientImpl@@UAE@XZ) referenced in function "public: virtual void * __thiscall PStatClientImpl::`scalar deleting destructor'(unsigned int)" (??_GPStatClientImpl@@UAEPAXI@Z)
1>jctut.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall PStatClientImpl::connection_reset(class PointerTo<class Connection> const &,bool)" (?connection_reset@PStatClientImpl@@EAEXABV?$PointerTo@VConnection@@@@_N@Z)
1>C:\Users\jc\Desktop\WORK\Panda\Release\jctut.exe : fatal error LNK1120: 8 unresolved externals

ok, sounds that in this case compiling the application c++ code with NDEBUG gets rid of the issue.

Now the question is: in this case is PSTAT still available?

This is by design. Optimize 4 means a production build, which leaves out all of these debugging tools intentionally. You wouldn’t want these tools in a production release.

It is possible to build a semi-production release that has some of these tools, for instance for the purpose of doing some performance measurement with PStats on a near-production release. Note, though, that having these tools available at all does have some small but nonzero impact on performance, which is why they’re normally left out of a production build.

David