OpenNMT / CTranslate

Lightweight C++ translator for OpenNMT Torch models (deprecated)
https://opennmt.net/
MIT License
79 stars 50 forks source link

Compile errors in Visual Studio #35

Closed ghost closed 6 years ago

ghost commented 6 years ago

I successfully compiled this repo in Ubuntu and want to transfer the lib to windows. With Cmake and Visual Studio, I tried but got some errors that cannot compile. It takes me 3 days to work on this and still not working. The error is in this line (matrixbatch.h 108): this->row(b).noalias() = Map<MatrixBatchBase>(mat.data(), 1, mat.cols() * mat.rows()); " Error C2672 'Eigen::PlainObjectBase<Eigen::Matrix<float,-1,-1,1,-1,-1>>::Map': no matching overloaded function found onmt c:\code\ctranslate\include\onmt\eigen\matrixbatch.h 108 Error C2975 'Eigen::PlainObjectBase<Eigen::Matrix<float,-1,-1,1,-1,-1>>::Map': invalid template argument for 'Outer', expected compile-time constant expression onmt c:\code\ctranslate\include\onmt\eigen\matrixbatch.h 108 "

guillaumekln commented 6 years ago

Did you try to debug this compilation error? If yes, I welcome a patch.

Unfortunately, I don't have a Windows system to test that at the moment.

jhnwnd commented 6 years ago

Seems like a Visual Studio compiler bug. The compiler is satisfied if your code explicitly gives the namespace (Eigen::Map instead of just Map), or if you change your definition of Map to another name (e.g., Mapp - i.e., using Mapp = ::Eigen::Map;). There are more compilation errors following this one, see pr #36. It is also necessary to build/use static libraries; changes are yet needed for DLL builds.