CxxWrap and visual C++ linkage error

I’ve been trying to use CxxWrap with the minimal example from the readme, using MS visual C 2017 (and 2015), CxxWrap 0.8.2 on Win10 64 bit and in both cases I’ve ended with

Creating library C:/Users/petr.hlavenka/.julia/packages/CxxWrap/sarOk/test/Debug/hello.lib and object C:/Users/petr.hlavenka/.julia/packages/CxxWrap/sarOk/test/Debug/hello.exp
2>hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl jlcxx::FunctionWrapperBase::FunctionWrapperBase(class jlcxx::Module *,struct _jl_datatype_t *)" (__imp_??0FunctionWrapperBase@jlcxx@@QEAA@PEAVModule@1@PEAU_jl_datatype_t@@@Z) referenced in function "public: __cdecl jlcxx::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class jlcxx::Module *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (__cdecl*)(void))" (??0?$FunctionPtrWrapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$$V@jlcxx@@QEAA@PEAVModule@1@P6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@Z)
2>hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl jlcxx::FunctionWrapperBase::~FunctionWrapperBase(void)" (__imp_??1FunctionWrapperBase@jlcxx@@UEAA@XZ) referenced in function "int `public: __cdecl jlcxx::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Module *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (__cdecl*)(void))'::`1'::dtor$0" (?dtor$0@?0???0?$FunctionPtrWrapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$$V@jlcxx@@QEAA@PEAVModule@1@P6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@Z@4HA)
2>hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl jlcxx::FunctionWrapperBase::set_name(struct _jl_value_t *)" (__imp_?set_name@FunctionWrapperBase@jlcxx@@QEAAXPEAU_jl_value_t@@@Z) referenced in function "public: class jlcxx::FunctionWrapperBase & __cdecl jlcxx::Module::method<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (__cdecl*)(void),bool)" (??$method@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$$V@Module@jlcxx@@QEAAAEAVFunctionWrapperBase@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6A?AV34@XZ_N@Z)
2>hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) protected: void __cdecl jlcxx::FunctionWrapperBase::set_pointer_indices(void)" (__imp_?set_pointer_indices@FunctionWrapperBase@jlcxx@@IEAAXXZ) referenced in function "public: __cdecl jlcxx::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::FunctionPtrWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class jlcxx::Module *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (__cdecl*)(void))" (??0?$FunctionPtrWrapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$$V@jlcxx@@QEAA@PEAVModule@1@P6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@Z)
2>hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl jlcxx::Module::append_function(class jlcxx::FunctionWrapperBase *)" (__imp_?append_function@Module@jlcxx@@QEAAXPEAVFunctionWrapperBase@2@@Z) referenced in function "public: class jlcxx::FunctionWrapperBase & __cdecl jlcxx::Module::method<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (__cdecl*)(void),bool)" (??$method@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@$$V@Module@jlcxx@@QEAAAEAVFunctionWrapperBase@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6A?AV34@XZ_N@Z)
2>C:\Users\petr.hlavenka\.julia\packages\CxxWrap\sarOk\test\Debug\hello.dll : fatal error LNK1120: 5 unresolved externals
2>Done building project "hello.vcxproj" -- FAILED.

Even the project file generated with cmake (should be bullet-proof) failed with the same linker error.

I’ve reported this as a issue CxxWrap.jl#156

After looking into the code for a while, what I don’t understand is the way the compiler should interpret lines that import class from a dll but some methods are overloaded (not virtual).
e.g. in module.hpp
class JLCXX_API Module that translates to class __declspec(dllimport) Module
According to this MSDN article it seems to me the code above should not be allowed with MSVC/Windows.
Could someone explain to me the principle it uses so I can fix my code or CxxWrap.
Do you know what is missing in my workflow? Is there a know bug?

I have a different issue, but my code works with previous version 0.8.1 of CxxWrap.jl. Maybe that is the easiest thing to test.

I’ve tried 0.8.1 with exactly the same result.
@Tero_Frondelius do you compile with MSVC or are you using different compiler?

I have only used BinaryBuilder.jl environment in my project. Here it is, if it helps: https://github.com/TeroFrondelius/mgisBuilder