samedi 4 juillet 2015

How to work with static variables in clases with the Android NDK?

I'm just trying to compile with NDK a simple class (that works with GCC compilation):

ShaderProgramManager.h:

namespace Graphics {

class ShaderProgramManager {
public:
    ShaderProgramManager();
    virtual ~ShaderProgramManager();
    static Graphics::ZGLProgram* ColoredVertexProgram;
};

} /* namespace Graphics */

ShaderProgramManager.cpp:

#include "ShaderProgramManager.h"

namespace Graphics {

ShaderProgramManager::ShaderProgramManager() {
    ShaderProgramManager::ColoredVertexProgram=new ZGLProgram();
}

The error is:

undefined reference to 'Graphics::ShaderProgramManager::ColoredVertexProgram'

If I declare the variable non-static there is no problem.

Aucun commentaire:

Enregistrer un commentaire