I'm trying to use the rdkit as a library in another project, and am having
trouble getting it to build on windows. I can get the code to compile on
mac and linux, but it fails for windows, both 32-big and 64-bit varieties.
I don't know how specific this is to the rdkit, but I have zero experience
compiling with visual studio (and very little C++ coding background) and I
am very confused here. The following is just a toy example showing the
minimum necessary for me to get the error. I get the same error using the
full code.
If I create a test class using this code, I can compile it just fine in
windows:
#include <GraphMol/GraphMol.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
class testClass{
testClass();
~testClass();
std::string testFunc() {
std::string smi = "CCC";
RDKit::ROMol mol = *(RDKit::SmilesToMol(smi));
std::string res = RDKit::MolToSmiles(mol);
return res;
};
};
testClass::testClass() {
}
testClass::~testClass() {
}
But if I move the definition of the testFunc() function outside of the
class declaration (which is the normal case, where the definitions are in
separate files), like this
#include <GraphMol/GraphMol.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
class testClass{
testClass();
~testClass();
std::string testFunc();
};
testClass::testClass() {
}
testClass::~testClass() {
}
std::string testClass::testFunc() {
std::string smi = "CCC";
RDKit::ROMol mol = *(RDKit::SmilesToMol(smi));
std::string res = RDKit::MolToSmiles(mol);
return res;
};
then I get the following linker errors:
error LNK2019: unresolved external symbol "private: virtual void __thiscall
RDKit::ROMol::destroy(void)" (?destroy@ROMol@RDKit@@EAEXXZ) referenced in
function "public: virtual __thiscall RDKit::ROMol::~ROMol(void)"
(??1ROMol@RDKit@@UAE@XZ)
failing.obj : error LNK2019: unresolved external symbol "private: void
__thiscall RDKit::ROMol::initFromOther(class RDKit::ROMol const
&,bool,int)" (?initFromOther@ROMol@RDKit@@AAEXABV12@_NH@Z) referenced in
function "public: __thiscall RDKit::ROMol::ROMol(class RDKit::ROMol const
&,bool,int)" (??0ROMol@RDKit@@QAE@ABV01@_NH@Z)
C:\Users\IEUser\Documents\rdkitlink_windows_compile_issue\Working-ie11win7-3268-3284-12\RDKitLink.dll
: fatal error LNK1120: 2 unresolved externals
I can't understand why moving the definition of testFunc() causes this
error.
Any help would be most appreciated. Clearly I can use the workaround of
making all definitions for testClass in the header file, but I would rather
not do that.
Thank you,
Jason
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss