On 13/05/2012 13:16, David Lonie wrote: > On Sun, May 13, 2012 at 7:15 AM, Chris Morley <c.mor...@gaseq.co.uk > <mailto:c.mor...@gaseq.co.uk>> wrote: > > On 12/05/2012 21:05, David Lonie wrote: > > On Wed, May 9, 2012 at 8:57 AM, Noel O'Boyle > <baoille...@gmail.com <mailto:baoille...@gmail.com> > <mailto:baoille...@gmail.com <mailto:baoille...@gmail.com>>> wrote: > > On 9 May 2012 13:22, David Lonie <david.lo...@kitware.com > <mailto:david.lo...@kitware.com> > <mailto:david.lonie@kitware.__com > <mailto:david.lo...@kitware.com>>> wrote: > > On Wed, May 9, 2012 at 7:42 AM, David Lonie > <david.lo...@kitware.com <mailto:david.lo...@kitware.com> > <mailto:david.lonie@kitware.__com > <mailto:david.lo...@kitware.com>>> wrote: > > On Wed, May 9, 2012 at 4:42 AM, Noel O'Boyle > <baoille...@gmail.com <mailto:baoille...@gmail.com> > <mailto:baoille...@gmail.com <mailto:baoille...@gmail.com>>> wrote: > > In the OB docs, there's an example C++ program. > Can you > edit this so that it reproduces the problem? > > > I'll give this a try. > > > Surprisingly, I was able to reproduce this on the > first try :-) > > Steps to reproduce with MSVC C++ 2010 Express: > > 1) File > New > Project > 2) Win32 Console Application, name openbabel-test > 3) Ok > 4) Next > 5) Check "Empty Project" > 6) Right click on Source Files in solution explorer, Add > > New > Item > C++ file, name main.cpp > Add > 7) Write source file: > > #include <iostream> > #include <openbabel/mol.h> > > int main(int argc, char **argv) > { > int atomicNum = 4; > std::cout << OpenBabel::etab.GetSymbol(__atomicNum) > <<" has an atomic number of " << atomicNum << std::endl; > return 0; > } > > 8) Right click on openbabel-test in solution explorer > > Properties > 9) Select C/C++ in tree, add "C:\Program Files > (x86)\openbabel\include\__openbabel-2" to Additional Include > Directories > 10) Select "Linker" in tree, add "C:\Program Files > (x86)\openbabel\bin" to Additional Library Directories > 11) Select "Linker" > "Input" in tree, add > openbabel-2.lib to > Additional Dependencies > 12) Build and fail: > > 1>------ Build started: Project: openbabel-test, > Configuration: > Debug Win32 ------ > 1>main.obj : error LNK2001: unresolved external symbol > "class > OpenBabel::OBElementTable OpenBabel::etab" > (?etab@OpenBabel@@__3VOBElementTable@1@A) > 1>c:\users\dl\documents\visual studio > 2010\Projects\openbabel-test\__Debug\openbabel-test.exe > : fatal > error LNK1120: 1 unresolved externals > ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 > skipped > ========== > > Can anyone reproduce? > > > Confirmed. It works fine if you create your own > OBElementTable, but > the linker cannot find the global etab. I'm going to have to > bounce > this on to Chris, whether he understands what's going on... > That's > strange though, because it's possible to access all of these > from > the Python interface, so they must be exposed (although I > haven't > checked this with MSVC 2010). > > > Hate to be a nag, but this is holding up my next release of > XtalOpt. > Any ideas what may be the problem? > > > Sorry, I've just returned from holiday. > > Adding a preprocessor definition USING_DYNAMIC_LIBS fixed the > problem for me, although I don't yet understand why it should. > > > That fixed it here also. Good call -- what made you think of that? > > Should I add this definition to my build system permanently for future > releases, or is this a bug that will go away?
I think it should always be defined - it is in the tools programs (including obabel). I suspect it works by ensuring that OB_IMPORT is defined in babelconfig.h. This is then used to define EXTERN which is used the declaration of etab, etc. in mol.h. The build also works without USING_DYNAMIC_LIBS if a line #define EXTERN __declspec(dllimport) extern is put at the very top of main.cpp. Chris ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel