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

[Opencv.js build] Build opencv.js with LLVM upstream backend failed #8986

Closed
Wenzhao-Xiang opened this issue Jul 15, 2019 · 5 comments
Closed
Labels

Comments

@Wenzhao-Xiang
Copy link

I'm trying to build opencv.js with LLVM upstream backend, but it failed.
I followed the opencv.js building steps here, and runned the command

python ./platforms/js/build_js.py build_simd --build_wasm --build_test --emscripten_dir="/home/gwy/Documents/webml/emsdk/upstream/emscripten"

, but got the following error:

error: undefined symbol: fp$_ZN2TH11THFile_freeEPNS_8THFile__E$vi
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: fp$_ZN2cv13HOGDescriptor24getDaimlerPeopleDetectorEv$vi
error: undefined symbol: fp$_ZN2cv13HOGDescriptor24getDefaultPeopleDetectorEv$vi
error: undefined symbol: fp$_ZN2cv18createMergeDebevecEv$vi
error: undefined symbol: fp$_ZN2cv20createMergeRobertsonEv$vi
error: undefined symbol: fp$_ZN2cv3hal10invSqrt32fEPKfPfi$viii
error: undefined symbol: fp$_ZN2cv3hal10invSqrt64fEPKdPdi$viii
error: undefined symbol: fp$_ZN2cv3hal4or8uEPKhmS2_mPhmiiPv$viiiiiiiii
error: undefined symbol: fp$_ZN2cv3hal5and8uEPKhmS2_mPhmiiPv$viiiiiiiii
error: undefined symbol: fp$_ZN2cv3hal5not8uEPKhmS2_mPhmiiPv$viiiiiiiii
error: undefined symbol: fp$_ZN2cv3hal5xor8uEPKhmS2_mPhmiiPv$viiiiiiiii
error: undefined symbol: fp$_ZN2cv3hal7sqrt32fEPKfPfi$viii
error: undefined symbol: fp$_ZN2cv3hal7sqrt64fEPKdPdi$viii
error: undefined symbol: fp$_ZN2cv9ExceptionD2Ev$ii
error: undefined symbol: fp$_ZN6google8protobuf15FieldDescriptor12TypeOnceInitEPKS1_$vi
error: undefined symbol: fp$_ZN6google8protobuf8internal15InitEmptyStringEv$v
error: undefined symbol: fp$_ZNK2cv17CascadeClassifier5emptyEv$ii
error: undefined symbol: fp$_ZNSt12length_errorD1Ev$ii
error: undefined symbol: fp$_ZNSt12out_of_rangeD1Ev$ii
error: undefined symbol: fp$_ZNSt8bad_castD1Ev$ii
error: undefined symbol: fp$zcalloc$iiii
error: undefined symbol: fp$zcfree$vii
error: undefined symbol: g$_ZN11opencv_onnx28_TypeProto_default_instance_E
error: undefined symbol: g$_ZN11opencv_onnx29_GraphProto_default_instance_E
error: undefined symbol: g$_ZN11opencv_onnx30_TensorProto_default_instance_E
error: undefined symbol: g$_ZN11opencv_onnx35_TensorShapeProto_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe19WindowDataParameter19_default_crop_mode_E
error: undefined symbol: g$_ZN12opencv_caffe28_BlobShape_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe31_ExpParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe31_LRNParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe31_MVNParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe32_DataParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe32_LossParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe32_ReLUParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe32_TanHParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe33_PowerParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe33_SliceParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe34_ArgMaxParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe34_ConcatParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe34_FillerParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe35_DropoutParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe35_EltwiseParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe35_PoolingParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe35_SigmoidParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe35_SoftmaxParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe35_V0LayerParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe36_AccuracyParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe36_HDF5DataParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe37_DummyDataParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe37_HingeLossParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe37_ImageDataParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe37_ThresholdParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe38_HDF5OutputParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe38_MemoryDataParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe38_WindowDataParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe39_ConvolutionParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe40_InfogainLossParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe40_InnerProductParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe42_TransformationParameter_default_instance_E
error: undefined symbol: g$_ZN12opencv_caffe43_ContrastiveLossParameter_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow24_OpDef_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow28_AttrValue_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow29_VersionDef_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow30_TensorProto_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow35_TensorShapeProto_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow37_FunctionDefLibrary_default_instance_E
error: undefined symbol: g$_ZN17opencv_tensorflow38_AttrValue_ListValue_default_instance_E
error: undefined symbol: g$_ZN2cv10g_8x32fTabE
error: undefined symbol: g$_ZN2cv12g_Saturate8uE
error: undefined symbol: g$_ZN2cv13__terminationE
error: undefined symbol: g$_ZN2cv15g_HersheyGlyphsE
error: undefined symbol: g$_ZN2cv3hal13popCountTableE
error: undefined symbol: g$_ZN6google8protobuf15DescriptorProto17kFieldFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf15DescriptorProto20kEnumTypeFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf15DescriptorProto21kExtensionFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf15DescriptorProto21kOneofDeclFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf15DescriptorProto22kNestedTypeFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf15FieldDescriptor11kTypeToNameE
error: undefined symbol: g$_ZN6google8protobuf15FieldDescriptor14kCppTypeToNameE
error: undefined symbol: g$_ZN6google8protobuf15FieldDescriptor17kTypeToCppTypeMapE
error: undefined symbol: g$_ZN6google8protobuf19EnumDescriptorProto17kValueFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf19FileDescriptorProto20kEnumTypeFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf19FileDescriptorProto21kExtensionFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf19FileDescriptorProto23kMessageTypeFieldNumberE
error: undefined symbol: g$_ZN6google8protobuf2io16CodedInputStream24default_recursion_limit_E
error: undefined symbol: g$_ZN6google8protobuf2io17CodedOutputStream36default_serialization_deterministic_E
error: undefined symbol: g$_ZN6google8protobuf30_EnumOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf30_FileOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf31_FieldOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf31_OneofOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf32_MethodOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf33_MessageOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf33_ServiceOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf33_SourceCodeInfo_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf35_EnumValueOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf40_ExtensionRangeOptions_default_instance_E
error: undefined symbol: g$_ZN6google8protobuf8internal14WireFormatLite21kWireTypeForFieldTypeE
error: undefined symbol: g$_ZN6google8protobuf8internal14WireFormatLite22kFieldTypeToCppTypeMapE
error: undefined symbol: g$_ZN6google8protobuf8internal14WireFormatLite23kMessageSetItemTagsSizeE
error: undefined symbol: g$_ZN6google8protobuf8internal16kAnyFullTypeNameE
error: undefined symbol: g$_ZN6google8protobuf8internal23empty_string_once_init_E
error: undefined symbol: g$_ZN6google8protobuf8internal24kTypeGoogleApisComPrefixE
error: undefined symbol: g$_ZN6google8protobuf8internal24kTypeGoogleProdComPrefixE
error: undefined symbol: g$_ZN6google8protobuf8internal24proto3_preserve_unknown_E
error: undefined symbol: g$_ZN6google8protobuf8internal26fixed_address_empty_stringE
error: undefined symbol: g$_ZNSt3__24cerrE
error: undefined symbol: g$_ZNSt3__24coutE
error: undefined symbol: g$_ZNSt3__25ctypeIcE2idE
error: undefined symbol: g$_ZNSt3__27codecvtIcc11__mbstate_tE2idE
error: undefined symbol: g$_ZSt7nothrow
error: undefined symbol: g$_ZTCNSt3__213basic_fstreamIcNS_11char_traitsIcEEEE0_NS_13basic_istreamIcS2_EE
error: undefined symbol: g$_ZTCNSt3__214basic_ifstreamIcNS_11char_traitsIcEEEE0_NS_13basic_istreamIcS2_EE
error: undefined symbol: g$_ZTCNSt3__218basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE
error: undefined symbol: g$_ZTCNSt3__219basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE
error: undefined symbol: g$_ZTCNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_ostreamIcS2_EE
error: undefined symbol: g$_ZTIN12opencv_caffe14LayerParameterE
error: undefined symbol: g$_ZTIN12opencv_caffe16V1LayerParameterE
error: undefined symbol: g$_ZTIN12opencv_caffe9ParamSpecE
error: undefined symbol: g$_ZTIN17opencv_tensorflow10VersionDefE
error: undefined symbol: g$_ZTIN17opencv_tensorflow11TensorProtoE
error: undefined symbol: g$_ZTIN17opencv_tensorflow16TensorShapeProtoE
error: undefined symbol: g$_ZTIN17opencv_tensorflow18FunctionDefLibraryE
error: undefined symbol: g$_ZTIN17opencv_tensorflow5OpDefE
error: undefined symbol: g$_ZTIN17opencv_tensorflow7NodeDefE
error: undefined symbol: g$_ZTIN17opencv_tensorflow9AttrValueE
error: undefined symbol: g$_ZTIN2cv12GFTTDetectorE
error: undefined symbol: g$_ZTIN2cv13HOGDescriptorE
error: undefined symbol: g$_ZTIN2cv17DescriptorMatcherE
error: undefined symbol: g$_ZTIN2cv19FastFeatureDetectorE
error: undefined symbol: g$_ZTIN2cv20AgastFeatureDetectorE
error: undefined symbol: g$_ZTIN2cv3ORBE
error: undefined symbol: g$_ZTIN2cv4KAZEE
error: undefined symbol: g$_ZTIN2cv4MSERE
error: undefined symbol: g$_ZTIN2cv5AKAZEE
error: undefined symbol: g$_ZTIN2cv5BRISKE
error: undefined symbol: g$_ZTIN2cv9AlgorithmE
error: undefined symbol: g$_ZTIN2cv9BFMatcherE
error: undefined symbol: g$_ZTIN2cv9ExceptionE
error: undefined symbol: g$_ZTIN2cv9Feature2DE
error: undefined symbol: g$_ZTIN6google8protobuf15DescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf19EnumDescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf20FieldDescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf20OneofDescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf21MethodDescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf22ServiceDescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf24EnumValueDescriptorProtoE
error: undefined symbol: g$_ZTIN6google8protobuf29DescriptorProto_ReservedRangeE
error: undefined symbol: g$_ZTIN6google8protobuf30DescriptorProto_ExtensionRangeE
error: undefined symbol: g$_ZTIN6google8protobuf37EnumDescriptorProto_EnumReservedRangeE
error: undefined symbol: g$_ZTIN6google8protobuf7MessageE
error: undefined symbol: g$_ZTINSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTISt12length_error
error: undefined symbol: g$_ZTISt12out_of_range
error: undefined symbol: g$_ZTISt8bad_cast
error: undefined symbol: g$_ZTIb
error: undefined symbol: g$_ZTIc
error: undefined symbol: g$_ZTId
error: undefined symbol: g$_ZTIf
error: undefined symbol: g$_ZTIh
error: undefined symbol: g$_ZTIi
error: undefined symbol: g$_ZTIj
error: undefined symbol: g$_ZTIl
error: undefined symbol: g$_ZTSNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTTNSt3__213basic_fstreamIcNS_11char_traitsIcEEEE
error: undefined symbol: g$_ZTTNSt3__214basic_ifstreamIcNS_11char_traitsIcEEEE
error: undefined symbol: g$_ZTTNSt3__218basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTTNSt3__219basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTTNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTVN2cv13HOGDescriptorE
error: undefined symbol: g$_ZTVN2cv9ExceptionE
error: undefined symbol: g$_ZTVN6google8protobuf2io18IstreamInputStreamE
error: undefined symbol: g$_ZTVN6google8protobuf8internal12MapFieldBaseE
error: undefined symbol: g$_ZTVN6google8protobuf8internal16FunctionClosure0E
error: undefined symbol: g$_ZTVN6google8protobuf8internal24GeneratedExtensionFinderE
error: undefined symbol: g$_ZTVN6google8protobuf8internal27UnknownFieldSetFieldSkipperE
error: undefined symbol: g$_ZTVNSt3__213basic_filebufIcNS_11char_traitsIcEEEE
error: undefined symbol: g$_ZTVNSt3__213basic_fstreamIcNS_11char_traitsIcEEEE
error: undefined symbol: g$_ZTVNSt3__213basic_istreamIcNS_11char_traitsIcEEEE
error: undefined symbol: g$_ZTVNSt3__214basic_ifstreamIcNS_11char_traitsIcEEEE
error: undefined symbol: g$_ZTVNSt3__215basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTVNSt3__218basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTVNSt3__219basic_istringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTVNSt3__219basic_ostringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE
error: undefined symbol: g$_ZTVSt12length_error
error: undefined symbol: g$_ZTVSt12out_of_range
error: undefined symbol: g$_dist_code
error: undefined symbol: g$_length_code
error: undefined symbol: g$icvSaturate8u_cv
error: undefined symbol: g$stderr
error: undefined symbol: g$stdout
error: undefined symbol: g$z_errmsg
error: undefined symbol: __memory_base
error: undefined symbol: __table_base
Error: Aborting compilation due to previous errors
shared:ERROR: '/home/gwy/Documents/webml/emsdk/node/8.9.1_64bit/bin/node /home/gwy/Documents/webml/emsdk/upstream/emscripten/src/compiler.js /tmp/tmp3FIrAJ.txt /home/gwy/Documents/webml/emsdk/upstream/emscripten/src/embind/emval.js /home/gwy/Documents/webml/emsdk/upstream/emscripten/src/embind/embind.js /home/gwy/Documents/webml/emsdk/upstream/emscripten/src/library_pthread_stub.js' failed (1)
modules/js/CMakeFiles/opencv_js.dir/build.make:179: recipe for target 'bin/opencv_js.js' failed
make[3]: *** [bin/opencv_js.js] Error 1
make[3]: Leaving directory '/home/gwy/Documents/opencvjs/opencv/build_simd'
CMakeFiles/Makefile2:1514: recipe for target 'modules/js/CMakeFiles/opencv_js.dir/all' failed
make[2]: *** [modules/js/CMakeFiles/opencv_js.dir/all] Error 2
make[2]: Leaving directory '/home/gwy/Documents/opencvjs/opencv/build_simd'
CMakeFiles/Makefile2:1479: recipe for target 'modules/js/CMakeFiles/opencv.js.dir/rule' failed
make[1]: *** [modules/js/CMakeFiles/opencv.js.dir/rule] Error 2
make[1]: Leaving directory '/home/gwy/Documents/opencvjs/opencv/build_simd'
Makefile:390: recipe for target 'opencv.js' failed
make: *** [opencv.js] Error 2
Traceback (most recent call last):
  File "./platforms/js/build_js.py", line 235, in <module>
    builder.build_opencvjs()
  File "./platforms/js/build_js.py", line 170, in build_opencvjs
    execute(["make", "-j", str(multiprocessing.cpu_count()), "opencv.js"])
  File "./platforms/js/build_js.py", line 23, in execute
    raise Fail("Child returned: %s" % retcode)
__main__.Fail: Child returned: 2

I try to use flag -s ERROR_ON_UNDEFINED_SYMBOLS=0, and the building passes. However, the opencv.js still doesn't work, and shows me:

failed to asynchronously prepare wasm: LinkError: WebAssembly.instantiate(): Import #261 module="env" function="__memory_base" error: global import must be a number or WebAssembly.Global object
LinkError: WebAssembly.instantiate(): Import #261 module="env" function="__memory_base" error: global import must be a number or WebAssembly.Global object
LinkError: WebAssembly.instantiate(): Import #261 module="env" function="__memory_base" error: global import must be a number or WebAssembly.Global object
Uncaught (in promise) abort("LinkError: WebAssembly.instantiate(): Import #261 module="env" function="__memory_base" error: global import must be a number or WebAssembly.Global object"). Build with -s ASSERTIONS=1 for more info.
@kripken
Copy link
Member

kripken commented Jul 15, 2019

I think this might be the current PIC bug - @sbc100 can confirm. If that's the case, then files are being built with -fPIC here, and removing that flag would fix things (until we fix that bug, which iirc is that PIC code only works if compiled to an actual shared library).

@Wenzhao-Xiang
Copy link
Author

@kripken Thanks for replying! I'm now using cmake toolchain to compile the opencv.js, so how can I remove the flag -fPIC? I'd like to have a try with that solution.

@huningxin
Copy link
Contributor

@kripken , thanks for the help. It is a duplicate of #8761. I can confirm opencv build works without -fPIC.

@Wenzhao-Xiang , I will comment the solution in opencv issue huningxin/opencv#257.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 17, 2019

See #9013

@stale
Copy link

stale bot commented Jul 16, 2020

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Jul 16, 2020
@stale stale bot closed this as completed Aug 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants