I am attempting to use the OFELI library in a CLI/C++ solution containing both C# and C++ projects, under VS2010. In short, the UI is written in WPF, and computations are done in CLR-enabled C++.
I downloaded the OFELI source, converted the solution to VS2010 format, and was able to successfully build the static lib. However, upon linking to the lib (ofeli-debug.lib) a slew of LNK2005 errors result;
error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP100D.dll)
I took care to insure that the lib was built with the /MDd setting, just as the project is. If I set the project to ignore msvcprtd.lib, I end up with a multitude of LNK2019 errors, as I'd expect.
Through experimentation, I've found that I can successfully link and use the ofeli lib from a non-CLR C++ test project, but not from a CLR enabled project (even if ofeli is compiled with CLR support enabled).
A simple code snippet which fails with many LNK2005 errors in my CLR project is below.
#include "stdafx.h"
#include <OFELI.h>
using namespace OFELI;
int _tmain(int argc, _TCHAR* argv[])
{
Mesh(10, 1); // Instance an object from the OFELI namespace
return 0;
}
What am I missing?