I've encountered a weird problem. My code works perfectly in Release build, but fails to compile in Debug. Quite the opposite to the problems one usually have. :)
in *.h file I have a constant:
class OBDenrChrg : public OBChargeModel
{
public:
bool ComputeCharges(OBMol &mol);
// blah-blah-blah
private:
static const float c = 0.05;
};
in *.cpp file I use this constant:
bool OBDenrChrg::ComputeCharges(OBMol &mol)
{
// blah-blah-blah
Eigen::VectorXf a0 = L*EN*c;
Eigen::SparseMatrix<float> A = L*HRD*c + I;
// blah-blah-blah
}
The built is controlled by cmake. The Release target builds and works well. The Debug says:
CMakeFiles/plugin_charges.dir/charges/denr.o:
In function `OpenBabel::OBDenrChrg::ComputeCharges(OpenBabel::OBMol&)':
/home/titov/openbabel-2.3.2/src/charges/denr.cpp:181: undefined reference to `OpenBabel::OBDenrChrg::c'
/home/titov/openbabel-2.3.2/src/charges/denr.cpp:182: undefined reference to `OpenBabel::OBDenrChrg::c'
I have no #ifdef DEBUG or similar switches in these files.
Any ideas on how to fix the problem and what may cause it?
Edit:
Thanks everyone for the help.
The problem was in the abscence of c
's definition, since declaration of a static
member inside of class
' definition does not define the static
member. What a mess...