Unresolved external with renderglobals.h on msvc


When I try to use the constants defined in renderglobals.h in a component in a custom module the linker generates unresolved external errors about these constants on MSVC. I suspect it might have something to do with the NAPAPI macro not working properly for these kind of external constants.


Hey, this is indeed correct, but has nothing to do with the NAPAPI macro, which is correct. The constants are not exported in the CPP, which is most likely the cause of the unresolved symbol. Which constants do you want to use?


It’s about projectionMatrixUniform, viewMatrixUniform and modelMatrixUniform in renderglobals.h/cpp


Right, yes, they can be used internally in the render module but because the definition is not exported it fails to resolve when referenced outside the dll. I think it makes more sense to wrap a function around them. Will add a ticket for this.


NAP 0.4.0 now exposes the render globals using a constexpr, which resolves your issue:

namespace uniform
	constexpr const char* mvpStruct = "nap";						///< default model view projection struct name
	constexpr const char* modelMatrix = "modelMatrix";				///< uniform model matrix name
	constexpr const char* viewMatrix = "viewMatrix";				///< uniform view matrix name
	constexpr const char* projectionMatrix = "projectionMatrix";	///< uniform projection matrix name