mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

unresolved external symbol mxnet::Symbol::CreateVariable,I already add the libmxnet.lib to the linker

Open zhubuntu opened this issue 10 years ago • 6 comments

I try the example file mlp.cpp. I have add the libmxnet.lib to the linker.But there were always compilation errors such as:

error LNK2001:  unresolved   external   symbol "public: static class mxnet::Symbol __cdecl mxnet::Symbol::CreateVariable(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"

zhubuntu avatar Dec 18 '15 03:12 zhubuntu

There should be a makefile came with the example. Did you use that?

piiswrong avatar Dec 18 '15 04:12 piiswrong

@piiswrong I use the VS2013 on win10,I dont't know how to use makefile with VS2013.This semms to be the problem of libmxnet.lib. I think the Ndarray and Symbol should also be contained in libmxnet.lib.But the Ndarray works fine, Symbol not.Is there something I configure wrong about the project?

zhubuntu avatar Dec 18 '15 07:12 zhubuntu

@zhubuntu I never try compiling MXNET in windows. I'll try it later.

Maybe @hjk41 could help you?

zhangchen-qinyinghua avatar Dec 18 '15 07:12 zhangchen-qinyinghua

@zhubuntu The problem is caused by not exporting Symbol in DLL library. NDArray is explicitly exported in the DLL, that's why the NDArray example works. A quick fix is to modify line 40 of symbolic.h into class MXNET_API Symbol { and then recompile libmxnet.dll.

@zhangchen-qinyinghua Can we modify the code so it uses APIs only in the c_api.h? That way we won't need to export the C++ classes and functions one by one.

hjk41 avatar Dec 18 '15 07:12 hjk41

@hjk41 Oh, I see. I think it could be done using APIs in c_api.h only. I will think about that.

zhangchen-qinyinghua avatar Dec 18 '15 08:12 zhangchen-qinyinghua

@hjk41 Thanks, it works.

zhubuntu avatar Dec 18 '15 10:12 zhubuntu