Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel C++ example link error on Windows 10 with Tensorflow 1.12 CPU #24499

Closed
georgescortaru opened this issue Dec 21, 2018 · 11 comments
Closed
Assignees
Labels
subtype:windows Windows Build/Installation Issues type:build/install Build and install issues

Comments

@georgescortaru
Copy link

C++ example build error on Windows 10 with Tensorflow 1.12

System information

  • OS Platform and Distribution Windows 10:
  • TensorFlow installed from source:
  • TensorFlow version: 1.12
  • Python version: 3.6
  • Installed using conda:
  • Bazel version (if compiling from source): 0.20.0
  • GCC/Compiler version (if compiling from source): Visual Studio 2015 tools
  • CUDA/cuDNN version: without GPU
  • GPU model and memory: without GPU

I cloned the Tensorflow Git repository and got the latest version from the master branch (commit [fe84b75] from Thursday, December 20, 2018 7:37:28 AM. I installed Bazel and I tried to compile the C++ example provided on the web site https://www.tensorflow.org/guide/extend/cc following the instructions. The required libraries from Tensorflow were compiled successfully but the example.cpp has a link error:

**C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/link.exe /nologo /OUT:bazel-out/x64_windows-opt/bin/tensorflow/cc/example/example.exe /SUBSYSTEM:CONSOLE -DEFAULTLIB:advapi32.lib /MACHINE:X64 @bazel-out/x64_windows-opt/bin/tensorflow/cc/example/example.exe-2.params /OPT:ICF /OPT:REF
Execution platform: @bazel_tools//platforms:host_platform
Creating library bazel-out/x64_windows-opt/bin/tensorflow/cc/example/example.lib and object bazel-out/x64_windows-opt/bin/tensorflow/cc/example/example.exp
pin_to_host_optimizer.lib(pin_to_host_optimizer.obj) : warning LNK4049: locally defined symbol ?DEVICE_CPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_CPU) imported
utils.lib(utils.obj) : warning LNK4049: locally defined symbol ?DEVICE_CPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_CPU) imported
batch_kernels.lo.lib(batch_kernels.obj) : warning LNK4217: locally defined symbol ?DEVICE_CPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_CPU) imported in function "void __cdecl tensorflow::dynamic initializer for 'registrar__body__0__object''(void)" (??__Eregistrar__body__0__object@tensorflow@@YAXXZ) captured_function.lib(captured_function.obj) : warning LNK4049: locally defined symbol ?DEVICE_CPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_CPU) imported arithmetic_optimizer.lib(arithmetic_optimizer.obj) : warning LNK4049: locally defined symbol ?DEVICE_CPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_CPU) imported memory_optimizer.lib(memory_optimizer.obj) : warning LNK4049: locally defined symbol ?DEVICE_CPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_CPU) imported unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ??3UMemory@icu_62@@SAXPEAX@Z (public: static void __cdecl icu_62::UMemory::operator delete(void *)) imported in function "public: virtual void * __cdecl icu_62::StringByteSink<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::scalar deleting destructor'(unsigned int)" (??_G?$StringByteSink@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@icu_62@@UEAAPEAXI@Z)
unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ??0UnicodeStringAppendable@icu_62@@qeaa@AEAVUnicodeString@1@@z (public: __cdecl icu_62::UnicodeStringAppendable::UnicodeStringAppendable(class icu_62::UnicodeString &)) imported in function "public: virtual void __cdecl tensorflow::UnicodeEncodeOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeEncodeOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ??1UnicodeStringAppendable@icu_62@@UEAA@XZ (public: virtual __cdecl icu_62::UnicodeStringAppendable::~UnicodeStringAppendable(void)) imported in function "public: virtual void __cdecl tensorflow::UnicodeEncodeOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeEncodeOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ?appendCodePoint@UnicodeStringAppendable@icu_62@@UEAACH@Z (public: virtual signed char __cdecl icu_62::UnicodeStringAppendable::appendCodePoint(int)) imported in function "public: virtual void __cdecl tensorflow::UnicodeEncodeOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeEncodeOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ??1ByteSink@icu_62@@UEAA@XZ (public: virtual __cdecl icu_62::ByteSink::~ByteSink(void)) imported in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > & __cdecl icu_62::UnicodeString::toUTF8String<class std::basic_string<char,struct std::char_traits,class std::allocator > >(class std::basic_string<char,struct std::char_traits,class std::allocator > &)const " (??$toUTF8String@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@UnicodeString@icu_62@@QEBAAEAV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@AEAV23@@z)
unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ?toUTF8@UnicodeString@icu_62@@QEBAXAEAVByteSink@2@@z (public: void __cdecl icu_62::UnicodeString::toUTF8(class icu_62::ByteSink &)const ) imported in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > & __cdecl icu_62::UnicodeString::toUTF8String<class std::basic_string<char,struct std::char_traits,class std::allocator > >(class std::basic_string<char,struct std::char_traits,class std::allocator > &)const " (??$toUTF8String@V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@UnicodeString@icu_62@@QEBAAEAV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@AEAV23@@z)
unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ?countChar32@UnicodeString@icu_62@@QEBAHHH@Z (public: int __cdecl icu_62::UnicodeString::countChar32(int,int)const ) imported in function "void __cdecl tensorflow::anonymous namespace'::Encode(enum tensorflow::UnicodeEncoding,class icu_62::UnicodeString const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?Encode@?A0xb9816742@tensorflow@@YAXW4UnicodeEncoding@2@AEBVUnicodeString@icu_62@@PEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ?append@UnicodeString@icu_62@@QEAAAEAV12@H@Z (public: class icu_62::UnicodeString & __cdecl icu_62::UnicodeString::append(int)) imported in function "private: void __cdecl tensorflow::UnicodeTranscodeOp::TranslateCodepoints(class icu_62::UnicodeString *,bool *,int,int,bool)" (?TranslateCodepoints@UnicodeTranscodeOp@tensorflow@@AEAAXPEAVUnicodeString@icu_62@@PEA_NHH_N@Z) unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ??0UnicodeString@icu_62@@QEAA@XZ (public: __cdecl icu_62::UnicodeString::UnicodeString(void)) imported in function "public: virtual void __cdecl tensorflow::UnicodeEncodeOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeEncodeOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@Z) unicode_ops.lo.lib(unicode_ops.obj) : warning LNK4217: locally defined symbol ??1UnicodeString@icu_62@@UEAA@XZ (public: virtual __cdecl icu_62::UnicodeString::~UnicodeString(void)) imported in function "public: virtual void __cdecl tensorflow::UnicodeEncodeOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeEncodeOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@Z) arithmetic_optimizer.lib(arithmetic_optimizer.obj) : warning LNK4217: locally defined symbol ?DEVICE_GPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_GPU) imported in function "private: bool __cdecl tensorflow::grappler::anonymous namespace'::ReorderCastLikeAndValuePreserving::NodeIsOnCpuOrGpu(class tensorflow::NodeDef const *)const " (?NodeIsOnCpuOrGpu@ReorderCastLikeAndValuePreserving@?A0x956ba610@grappler@tensorflow@@AEBA_NPEBVNodeDef@4@@z)
layout_optimizer.lib(layout_optimizer.obj) : warning LNK4049: locally defined symbol ?DEVICE_GPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_GPU) imported
memory_optimizer.lib(memory_optimizer.obj) : warning LNK4049: locally defined symbol ?DEVICE_GPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_GPU) imported
pin_to_host_optimizer.lib(pin_to_host_optimizer.obj) : warning LNK4049: locally defined symbol ?DEVICE_GPU@tensorflow@@3QEBDEB (char const * const tensorflow::DEVICE_GPU) imported
unicode_ops.lo.lib(unicode_ops.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual int __cdecl icu_62::UCharCharacterIterator::next32PostInc(void)" (_imp?next32PostInc@UCharCharacterIterator@icu_62@@UEAAHXZ) referenced in function "void __cdecl tensorflow::anonymous namespace'::Encode(enum tensorflow::UnicodeEncoding,class icu_62::UnicodeString const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?Encode@?A0xb9816742@tensorflow@@YAXW4UnicodeEncoding@2@AEBVUnicodeString@icu_62@@PEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) unicode_ops.lo.lib(unicode_ops.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual signed char __cdecl icu_62::UCharCharacterIterator::hasNext(void)" (__imp_?hasNext@UCharCharacterIterator@icu_62@@UEAACXZ) referenced in function "void __cdecl tensorflow::anonymous namespace'::Encode(enum tensorflow::UnicodeEncoding,class icu_62::UnicodeString const &,class std::basic_string<char,struct std::char_traits,class std::allocator > *)" (?Encode@?A0xb9816742@tensorflow@@YAXW4UnicodeEncoding@2@AEBVUnicodeString@icu_62@@peav?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z)
unicode_ops.lo.lib(unicode_ops.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl icu_62::StringCharacterIterator::StringCharacterIterator(class icu_62::UnicodeString const &)" (_imp??0StringCharacterIterator@icu_62@@qeaa@AEBVUnicodeString@1@@z) referenced in function "void __cdecl tensorflow::anonymous namespace'::Encode(enum tensorflow::UnicodeEncoding,class icu_62::UnicodeString const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?Encode@?A0xb9816742@tensorflow@@YAXW4UnicodeEncoding@2@AEBVUnicodeString@icu_62@@PEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) unicode_ops.lo.lib(unicode_ops.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl icu_62::StringCharacterIterator::~StringCharacterIterator(void)" (__imp_??1StringCharacterIterator@icu_62@@UEAA@XZ) referenced in function "void __cdecl tensorflow::anonymous namespace'::Encode(enum tensorflow::UnicodeEncoding,class icu_62::UnicodeString const &,class std::basic_string<char,struct std::char_traits,class std::allocator > *)" (?Encode@?A0xb9816742@tensorflow@@YAXW4UnicodeEncoding@2@AEBVUnicodeString@icu_62@@peav?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z)
unicode_script_op.lo.lib(unicode_script_op.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl icu_62::ErrorCode::~ErrorCode(void)" (_imp??1ErrorCode@icu_62@@UEAA@XZ) referenced in function "public: virtual void __cdecl tensorflow::UnicodeScriptOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeScriptOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
unicode_script_op.lo.lib(unicode_script_op.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: signed char __cdecl icu_62::ErrorCode::isSuccess(void)const " (_imp?isSuccess@ErrorCode@icu_62@@QEBACXZ) referenced in function "public: virtual void __cdecl tensorflow::UnicodeScriptOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeScriptOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
unicode_script_op.lo.lib(unicode_script_op.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum UErrorCode __cdecl icu_62::ErrorCode::reset(void)" (_imp?reset@ErrorCode@icu_62@@qeaa?AW4UErrorCode@@xz) referenced in function "public: virtual void __cdecl tensorflow::UnicodeScriptOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeScriptOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
unicode_script_op.lo.lib(unicode_script_op.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) const icu_62::ErrorCode::`vftable'" (_imp??_7ErrorCode@icu_62@@6b@) referenced in function "public: virtual void __cdecl tensorflow::UnicodeScriptOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeScriptOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@z)
icuuc.lib(udata.obj) : error LNK2019: unresolved external symbol __imp_icudt62_dat referenced in function "struct UDataMemory * __cdecl openCommonData(char const *,int,enum UErrorCode *)" (?openCommonData@@YAPEAUUDataMemory@@PEBDHPEAW4UErrorCode@@@z)
bazel-out/x64_windows-opt/bin/tensorflow/cc/example/example.exe : fatal error LNK1120: 9 unresolved externals
Target //tensorflow/cc/example:example failed to build
INFO: Elapsed time: 19976.467s, Critical Path: 13898.60s
INFO: 1461 processes: 1461 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
**

Thank you for help!

@ymodak ymodak self-assigned this Dec 21, 2018
@rootkitchao
Copy link

Can the current version of the Tensorflow C++ API work under Windows?

@matt-har-vey
Copy link

For myself, for now, I am content with just not linking the Unicode ops as a workaround.

https://gist.github.com/matth79/224962f167f01cd41ba21039eab51fbc

The correct solution is more along these lines:

#23655

@georgescortaru
Copy link
Author

Thanks,
The solution from https://gist.github.com/matth79/224962f167f01cd41ba21039eab51fbc worked

@ymodak ymodak added type:build/install Build and install issues subtype:windows Windows Build/Installation Issues labels Jan 15, 2019
@ymodak
Copy link
Contributor

ymodak commented Jan 18, 2019

Closing this issue since its resolved. Feel free to reopen if have any further problems. Thanks!

@ymodak ymodak closed this as completed Jan 18, 2019
@gmt710
Copy link

gmt710 commented Jun 8, 2019

I solved the problem by compiling icu4c,adding the path of lib64.

@gmt710
Copy link

gmt710 commented Jun 8, 2019

image
image

@jesen8
Copy link

jesen8 commented Jul 18, 2019

@gmt710 hi,can you teach me how to build tf on vs?

@gmt710
Copy link

gmt710 commented Jul 19, 2019

@jesen8 hello,I wrote the installation instructions.May you follow this:windows+bazel+tensorflow-v1.12.0(GPU).

@jesen8
Copy link

jesen8 commented Jul 19, 2019

thanks!,can you give me your wchart id?

@jesen8
Copy link

jesen8 commented Jul 19, 2019

@gmt710

@gmt710
Copy link

gmt710 commented Jul 20, 2019

@jesen8 hi,Can you email me, OK?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subtype:windows Windows Build/Installation Issues type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

6 participants