I today use CMake generates 2 projects (particlefx+sample). the program can run, but all variables in DLL not initialized. that's too weird,the program runs no problem before.
any advice?
all static variables are not initialized
-
- Halfling
- Posts: 77
- Joined: Mon Mar 23, 2015 3:57 pm
- Location: Vancouver,BC,Canada
- x 1
-
- Halfling
- Posts: 77
- Joined: Mon Mar 23, 2015 3:57 pm
- Location: Vancouver,BC,Canada
- x 1
Re: all static variables are not initialized
When I build the project, I found this:
I googled on internet, there is no good method, somebody suggests use a static function,like this: but it seems not good, any advice?
Code: Select all
OgreAreaEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreBoxEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreColourFaderAffector2V2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreColourFaderAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreColourImageAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreColourInterpolatorAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreCylinderEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreDeflectorPlaneAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreDirectionRandomiserAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreEllipsoidEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreHlmsParticle.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreHlmsParticleDatablock.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreHollowEllipsoidEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreLinearForceAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleBatchManager.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleBatchV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleBufferManager.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleContainer.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleEmitterCommandsV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleFXPluginV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleFXV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleIterator.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleProcessor.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleScript.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleScriptExecutor.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleScriptLoader.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleSystemV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleTask.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleTaskManager.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreParticleTranslator.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgrePointEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreRingEmitterV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreRotationAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreScaleAffectorV2.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreHlmsBufferManager.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreUnlitProperty.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>OgreSamplesCommon_d.lib(MessageQueueSystem.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>libboost_system-vc120-mt-gd-1_57.lib(error_code.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>msvcprtd.lib(nothrow.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>MSVCRTD.lib(atonexit.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
I googled on internet, there is no good method, somebody suggests use a static function,like this:
Code: Select all
class MyClass
{
// some other stuff here
...
private:
static AnotherClass* const getAnotherClass();
};
AnotherClass *const MyClass::getAnotherClass()
{
static AnotherClass *const p = new AnotherClass("");
return(p);
}
-
- Halfling
- Posts: 77
- Joined: Mon Mar 23, 2015 3:57 pm
- Location: Vancouver,BC,Canada
- x 1
Re: all static variables are not initialized
I found the problem. In my linker I added SDL.lib. This cause the error
Here is my Cmakelist.txt. I don't know Is there anything to add SDL2.lib.
thanks
Code: Select all
D:\ogre_Others\SDL2-2.0.3\SDL2-2.0.3\build\Debug\SDL2.lib;
Code: Select all
# Configure NewParticleFX Plugin build
file(GLOB HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" "${OGRE_SOURCE_DIR}/Components/Hlms/Common/include/*.h" "${OGRE_SOURCE_DIR}/Components/Hlms/Unlit/include/OgreHlmsUnlitPrerequisites.h" "${OGRE_SOURCE_DIR}/Components/Hlms/Unlit/include/OgreUnlitProperty.h")
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${OGRE_SOURCE_DIR}/Components/Hlms/Common/src/*.cpp" "${OGRE_SOURCE_DIR}/Components/Hlms/Unlit/src/OgreUnlitProperty.cpp")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${OGRE_SOURCE_DIR}/Components/Hlms/Unlit/include)
include_directories(${OGRE_SOURCE_DIR}/Components/Hlms/Common/include)
include_directories(${OGRE_SOURCE_DIR}/Samples/2.0/Common/include)
add_definitions(-D_USRDLL)
add_definitions(-DOgreHlmsUnlit_EXPORTS)
ogre_add_library(Plugin_NewParticleFX ${OGRE_LIB_TYPE} ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(Plugin_NewParticleFX OgreMain)
target_link_libraries(Plugin_NewParticleFX OgreHlmsUnlit)
target_link_libraries(Plugin_NewParticleFX OgreSamplesCommon)
if (NOT OGRE_STATIC)
set_target_properties(Plugin_NewParticleFX PROPERTIES
COMPILE_DEFINITIONS OGRE_NEWPARTICLEFXPLUGIN_EXPORTS
)
endif ()
ogre_config_framework(Plugin_NewParticleFX)
ogre_config_plugin(Plugin_NewParticleFX)
install(FILES ${HEADER_FILES} DESTINATION include/OGRE/Plugins/NewParticleFX)
thanks