I am a new user of tensorflow. I wish to integrate a specific graph.pb file into an ios device, and have followed all the compilation instructions carefully as described in tensorflow git.
yet when I try to run the camera example app I get the error:
E /tensorflow/tensorflow/examples/ios/camera_copy/tensorflow_utils.mm:140] Could not create TensorFlow Graph: Invalid argument: No OpKernel was registered to support Op 'Conv2D' with these attrs. Registered devices: [CPU], Registered kernels:
<no registered kernels>
[[{{node pyramid_regression_0/convolution}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](input_2, pyramid_regression_0/kernel/read)]]
2018-08-22 16:54:00.303760: F tensorflow/examples/ios/camera_copy/tensorflowUtil.mm:68] Couldn't load model: Invalid argument: No OpKernel was registered to support Op 'Conv2D' with these attrs. Registered devices: [CPU], Registered kernels:
<no registered kernels>
[[{{node pyramid_regression_0/convolution}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](input_2, pyramid_regression_0/kernel/read)]]
I also followed the instructions according to the solution offered in here, but I got there are some differences (probably due to the versions diffs between a year ago and now (Aug 2018))
bazel build --copt="-DUSE_GEMM_FOR_CONV" tensorflow/python/tools/print_selective_registration_header compiled without errors
then created the ops_to_register.h file:
when used the bazel-bin command, it adds a strange print of tf.estimator package not installed to the first line.
In addition, during the file creation this warning appears multiple times:
RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
when I create the ops_to_register.h file using python3 , it creates the file without strange prints
in both cases there are no occurrences of strcmp or strcmpc at all, and got Conv2DUsingGemmOp op in the bazel created file instead of Conv2DOp by python3
I tried to use the ops_to_register.h file for the tensorflow/contrib/makefile/compile_ios_tensorflow.sh compilation, but it fails during the compilation:
Undefined symbols for architecture arm64:
"nsync::nsync_cv_signal(nsync::nsync_cv_s_)", referenced from:
tensorflow::condition_variable::notify_one() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_cv_wait_with_deadline(nsync::nsync_cv_s_, nsync::nsync_mu_s_, timespec, nsync::nsync_note_s_)", referenced from:
tensorflow::condition_variable::wait_until_system_clock(tensorflow::mutex_lock&, std::__1::chrono::time_point > >) in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_cv_init(nsync::nsync_cv_s_)", referenced from:
tensorflow::condition_variable::condition_variable() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_from_time_point_(std::__1::chrono::time_point > >)", referenced from:
tensorflow::condition_variable::wait_until_system_clock(tensorflow::mutex_lock&, std::__1::chrono::time_point > >) in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_cv_wait(nsync::nsync_cv_s_, nsync::nsync_mu_s_)", referenced from:
tensorflow::condition_variable::wait(tensorflow::mutex_lock&) in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_mu_runlock(nsync::nsync_mu_s_)", referenced from:
tensorflow::mutex::unlock_shared() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_mu_rlock(nsync::nsync_mu_s_)", referenced from:
tensorflow::mutex::lock_shared() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_mu_unlock(nsync::nsync_mu_s_)", referenced from:
tensorflow::mutex::unlock() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_mu_lock(nsync::nsync_mu_s_)", referenced from:
tensorflow::mutex::lock() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_cv_broadcast(nsync::nsync_cv_s_)", referenced from:
tensorflow::condition_variable::notify_all() in libtensorflow-core-arm64.a(mutex.o)
"nsync::nsync_mu_init(nsync::nsync_mu_s_*)", referenced from:
tensorflow::mutex::mutex() in libtensorflow-core-arm64.a(mutex.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make:
[/tensorflow/tensorflow/contrib/makefile/gen/bin/ios_ARM64/benchmark] Error 1
'[' 2 -ne 0 ']'
echo 'arm64 compilation failed.'
arm64 compilation failed.
exit 1
environment details:
tensorflow 1.9.0 (there is tensorflow 1.10.0, but is currently not supported for the ios compilations)
python 3.6.6
all the compilations are done with -a arm64 only
does anyone have an idea what went wrong here?
thanks a lot
I once had a similar error when compiling for the raspberry pi, I had to manually export the environment variables HOST_NSYNC_LIB and TARGET_NSYNC_LIB
First check if you have them already exported: echo $HOST_NSYNC_LIB
if that is empty you should look where your nsync library is compiled (just look for libnsync.a)
Then export both paths:
export HOST_NSYNC_LIB='your/path/to/libnsync.a'
export TARGET_NSYNC_LIB="$HOST_NSYNC_LIB"
Hope this works for you!
Related
I'm trying to build an iOS application using QT6.4.2 and Cmake, I'm getting following linking error
Undefined symbols for architecture arm64:
"_main", referenced from:
user_main_trampoline() in libqios_debug.a(qioseventdispatcher.mm.o)
(maybe you meant: _jinit_d_main_controller, _jinit_c_main_controller , _qt_main_wrapper )
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
this is m list of installed libs
My main entry point looks like this
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
// ...
return app.exec();
}
following is my cmake script
set(TARGET_NAME Focus)
set(CMAKE_SUPPRESS_REGENERATION true)
include(../cute.cmake)
include(../files.cmake)
cute_add_executable(${TARGET_NAME})
target_sources(${TARGET_NAME}
PRIVATE
${FOCUS_HEADER}
${OBJECTIVE_HEADER}
${COMMON_HEADER}
${FOCUS_SOURCE}
${OBJECTIVE_SOURCE}
${COMMON_SOURCE}
${QUICK_IOS_SOURCE}
${FOCUS_QML_SOURCE}
${QUICK_IOS_QML_SOURCE}
${QRC_FILES}
${QT_QML_PLUGIN_CPP}
)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core OpenGL Concurrent Widgets Multimedia Network Sql Qml Quick QuickWidgets Svg WebView QuickControls2 Core5Compat REQUIRED)
# set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-Wl,-e,_qt_main_wrapper")
# set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-u _qt_registerPlatformPlugin")
target_link_libraries(${TARGET_NAME}
PRIVATE
#MySharedLibrary
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::OpenGL
Qt${QT_VERSION_MAJOR}::Multimedia
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Sql
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::QuickControls2
Qt${QT_VERSION_MAJOR}::QuickWidgets
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::WebView
Qt${QT_VERSION_MAJOR}::Core5Compat
)
if (${QT_VERSION_MAJOR} EQUAL 6)
qt6_import_qml_plugins(${TARGET_NAME})
endif ()
file(GLOB LOCAL_LIB_FILES "${CMAKE_SOURCE_DIR}/lib/ios/*.a")
message("CMAKE_SOURCE_DIR : " ${CMAKE_SOURCE_DIR})
target_link_libraries(${TARGET_NAME}
PRIVATE
${LOCAL_LIB_FILES}
)
Any guidance/help is appreciated.
I've already gone through following posts from QT community and SO but no luck,
https://forum.qt.io/topic/136707/undefined-symbols-_main-when-building-a-shared-lib-on-ios-with-qt-statemachine
https://forum.qt.io/topic/80775/main-function-required-when-compiling-shared-library-for-ios
QT IOS linker error entry point (_main) undefined
LINKER COMMAND: https://pastebin.com/CdARmarQ
CMAKE SCRIPT: https://pastebin.com/xXnCUKC6
NOTE: I've used https://github.com/cuteserver/hello-world as my toolchain and qt configuration for iOS.
We are unable to distribute our sample app which uses our framework as well as our users can't.
While archiving and distributing to AppStore, the app is rejected with the following message:
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path. If your app contains bitcode, bitcode processing may have failed. Because of these errors, this build of your app will not be able to be submitted for review or placed on the App Store.
The framework contain the bitcode, or at least there's a BITCODE_GENERATION_MODE = bitcode build setting in our .xcconfig, which basically means, the Xcode will add -fembed-bitcode build flag to any clang invocation.
From here, we've started testing using Ad-Hoc builds, to speed up our trial and error attempts, which also fails while Rebuild from bitcode option is selected. Organiser shows the popup with the following contents:
ipatool failed with an exception: #<CmdSpec::NonZeroExitException: $ /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool -v -t /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.2.sdk -o /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/ipatool20201130-52097-13rj9hy/thinned-out/arm64/Payload/iosTest.app/Frameworks/SciChart.framework/SciChart --generate-dsym /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/ipatool20201130-52097-13rj9hy/thinned-out/arm64/Payload/iosTest.app/Frameworks/SciChart.framework/SciChart.dSYM --strip-swift-symbols /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/ipatool20201130-52097-13rj9hy/thinned-in/arm64/Payload/iosTest.app/Frameworks/SciChart.framework/SciChart
Status: pid 52150 exit 1
Stdout:
SDK path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
Logs provided isn't very informative, here is the snippet from IDEDistributionPipeline.log
-= Output =-
ld: warning: -sdk_version and -platform_version are not compatible, ignoring -sdk_version
Undefined symbols for architecture arm64:
"___llvm_profile_runtime", referenced from:
__hidden#25821_ in 0832.o
__hidden#25821_ in 0833.o
__hidden#25821_ in 0834.o
__hidden#25821_ in 0835.o
__hid
2020-11-30 16:19:17 +0000 den#25821_ in 0836.o
__hidden#25821_ in 0837.o
__hidden#25821_ in 0838.o
...
ld: symbol(s) not found for architecture arm64
Exited with 1z
Failed to compile bundle: /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/SciChart6aun_sfs/SciChart.arm64.xar
Stderr:
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2808:in `block in CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2747:in `each'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2747:in `CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3016:in `block in ProcessIPA'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2978:in `each'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2978:in `ProcessIPA'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3928:in `<main>'
2020-11-30 16:19:17 +0000 /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1
which after bunch of warnings shows the actual error at the end of file (I can't include full log, since it's too much of a raw text):
code = 1061;
description = "ipatool failed with an exception: #<CmdSpec::NonZeroExitException: ...
info = {
};
level = ERROR;
type = exception;
Not sure what to to do with this, I've tried different build settings options, nothing helped... Already contacted apple, but no feedback yet, and knowing them, we can wait far too long...
The strange part here, is if we include our .framework directly as a source code and then archive the app - everything works as expected. If we include it as XCFramework or just .framework, which is pre-built - it fails as described above.
I might miss something simple or obvious here, so please let me know if somebody have some insights on that matter.
Some system info:
macOS BigSur 11.0.1
XCode Version 12.2 (12B45b)
We've tried different combinations of macOS and Xcode, e.g.:
Catalina with Xcode 12
BigSur with Xcode 11
etc.
Any help is greatly appreciated.
Thanks.
Long story short, there were LLVM instrumentation included, which prevents AppStore processing. I've written a whole blog post about it here - https://blog.scichart.com/xcframework-xcode-12-and-bigsur-issues/
To sum up, here is a few required steps to make sure while creating XCFramework for distribution:
Using archive builds is a MUST, release build isn't enough
BUILD_LIBRARY_FOR_DISTRIBUTION must be set to YES
SKIP_INSTALL must be set to NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO to turn off GCC instrumentation and remove them from the binary
CLANG_ENABLE_CODE_COVERAGE = NO to turn off code coverage tools from the binary
Having all of the above helped to solve our preparing and distribution problem and hopefully save you some time if you happened to face same issues as we did.
I use the ffmpeg version is 3.0, Xcode version 7.3.1, compile time has been reported as the following error:
Undefined symbols for architecture x86_64:
"_libiconv", referenced from:
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_libiconv_close", referenced from:
_avcodec_open2 in libavcodec.a(utils.o)
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_libiconv_open", referenced from:
_avcodec_open2 in libavcodec.a(utils.o)
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My project has been introduced in the following framework and library:
1.VideoToolbox.framework
2.libiconv.2.4.0.tbd
3.libz.tbd
4.libbz2.tbd
I agree with Eureka.gh. The root cause should be symbol mismatch.
I show my test result below.
LiaotekiMacBook-Pro:lib liaokuohsun$ nm libavcodec.a | grep iconv
U _libiconv
U _libiconv_close
U _libiconv_open
LiaotekiMacBook-Pro:lib liaokuohsun$ nm libiconv.dylib | grep iconv
00000000000f2d80 S ___iconv_2VersionNumber
00000000000f2d50 S ___iconv_2VersionString
00000000000f4750 D __libiconv_version
0000000000003174 T _iconv
00000000000034b7 T _iconv_canonicalize
0000000000003196 T _iconv_close
0000000000001cdd T _iconv_open
00000000000031a3 T _iconvctl
00000000000032ac T _iconvlist
0000000000015f0d T _libiconv_relocate
00000000000f4760 b _libiconv_relocate.initialized
0000000000015e54 T _libiconv_set_relocation_prefix
Here I provide another solution.
With some wrapper functions in your code, this link error can be fixed.
#include <iconv.h>
iconv_t libiconv_open(const char *tocode, const char *fromcode)
{
return iconv_open(tocode, fromcode);
}
size_t libiconv(iconv_t cd,
char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
return iconv( cd, inbuf, inbytesleft, outbuf, outbytesleft);
}
int libiconv_close(iconv_t cd)
{
return iconv_close(cd);
}
I have the same issue with you. What I found is that the libiconv.tbd (or libiconv2.tbd or libiconv2.4.0.tbd) comes from macOS 10.12(in my case) have compatible issue where the exported symbols are iconv/iconv_open/iconv_close whereas ffmpeg calls libiconv functions like libiconv/libiconv_open/libiconv_close.
Solution is to remove libiconv.2.4.0 from framework/library and one specific version of libiconv.a where libiconv/libiconv_open/libiconv_close are the exported symbols. In my case, I found another copy of libiconv.a in /opt/local/lib. I simply copy this lib file to my project and add it.
Please have a try and let me know if it's able to resolve your issue.
I tried to use LibEtPan as a backend for a mail client. I downloaded the source code from https://github.com/dinhviethoa/libetpan and additional libs from https://github.com/bindle/iOSPorts too. I ran the LibEtPan build-mac/update.sh and added the libetpan.xcodeproj to my project as well as openldap.xcodeproj, openssl.xcodeproj, Cyrus SASL.xcodeproj.
I set the following Target Dependencies: libetpan ios (libetpan), lber (openldap), ldap (openldap), crypto (openssl), ssl (openssl), sasl2 (Cyrus SASL) and I Linked Binary With Libraries: libetpan-ios.a, libiconv.dylib, liblber.a, libldap.a, libcrypto.a, libsasl2, libssl.a
But as soon as I call something like mailimap_new i get the error message:
Undefined symbols for architecture i386:
"_mailimap_extension_xgmmsgid", referenced from:
_internal_extension_list in libetpan-ios.a(mailimap_extension.o)
(same with armv7 or other architectures)
I have no idea which lib i have to include additionally.
Following this link. I am stuck in the last two steps during setting up my workstation.
As a compiler I use Code:Block MinGW; I have already generated the compiled opencv files, now I need to build the sln file in Windows. I use Code Block to build this OpenCV Project File in the path D:\OpenCV\Build\Opencv, where I put the generated bin file after using Cmake.
During the building, it stopped at 40%, saying;
Linking CXX executable ....\bin\opencv_perf_core.exe
c:/codeblock/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe:
warning: auto-importing has been activated without
--enable-auto-import specified on the command line. This should work unless it involves constant data structures referencing symbols from
auto-imported DLLs. Cannot export _ZN12_GLOBAL__N_13ROp3allEv: symbol
not found Cannot export _ZN12_GLOBAL__N_17CmpType3allEv: symbol not
found collect2: ld returned 1 exit status mingw32-make.exe[2]: *
[bin/opencv_perf_core.exe] Error 1 mingw32-make.exe1: *
[modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
mingw32-make.exe: * [all] Error 2 Info: resolving vtable for
cv::_OutputArray by linking to imp_ZTVN2cv12_OutputArrayE
(auto-import) Info: resolving vtable for cv::_InputArray by linking to
imp_ZTVN2cv11_InputArrayE (auto-import) Info: resolving vtable for cv::Exception by linking to imp_ZTVN2cv9ExceptionE (auto-import)
Creating library file: ....\bin\libopencv_perf_core.dll.a Process
terminated with status 2 (14 minutes, 29 seconds) 0 errors, 3 warnings
How can I solve this problem?
Unfortunately, there's not much you can do, according to http://code.opencv.org/issues/2523.
You will have to use a recent version of MinGW. It builds fine using the latest MinGW shipping with GCC 4.7.2.
This issue seems to have been introduced in OpenCV 2.4.3 as it is said version 2.4.2 builds fine.