MediaPipe library build on macOS - macos

I'm trying to build MediaPipe as library on macOS to be able to use it in a
desktop project with CMake, but I'm running into issues. I'm trying to convert
the Hello World example to a library, using hello_world.cc with MediaPipe as
an external lib. I tried static and dynamic library build as well, but I have
encountered issues with both of them.
At the moment I'm stuck and any help would be greatly appreciated.
The steps of building the libraries and the received errors are below:
As a static library
I created a file mediapipe/lib/BUILD with the following content
apple_static_library(
name = "mediapipe",
minimum_os_version = "10.14",
platform_type = "macos",
deps = [
"//mediapipe/calculators/core:pass_through_calculator",
"//mediapipe/framework:calculator_graph",
"//mediapipe/framework/port:logging",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/port:status",
],
)
Built the lib
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/lib:mediapipe
Copied bazel-out/apl-darwin_x86_64-opt/bin/mediapipe/lib/mediapipe_lipo.a to my desktop project
The project has been built without errors, but it gives the following errors when ran:
Not found: ValidatedGraphConfig Initialization failed.
No registered object with name: PassThroughCalculator; Unable to find Calculator "PassThroughCalculator"
No registered object with name: PassThroughCalculator; Unable to find Calculator "PassThroughCalculator"
As a dynamic library
I read some github issues that building an iOS dynamic library does not exhibit the problems above.
Bazel build file mediapipe/dylib/BUILD with the following content
load("#build_bazel_rules_apple//apple:macos.bzl", "macos_dylib")
macos_dylib(
name = "mediapipe",
minimum_os_version = "10.15",
deps = [
"//mediapipe/framework:calculator_framework",
"//mediapipe/framework/port:commandlineflags",
"//mediapipe/framework/port:file_helpers",
"//mediapipe/framework/port:map_util",
"//mediapipe/framework/port:parse_text_proto",
"//mediapipe/framework/port:ret_check",
"//mediapipe/framework/port:status",
"//mediapipe/framework/port:statusor",
"#com_google_absl//absl/strings",
#"//mediapipe/graphs/hand_tracking:desktop_tflite_calculators",
"//mediapipe/calculators/core:pass_through_calculator",
],
)
Built the dylib
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/dylib:mediapipe
Fixed the dylib id
chmod 755 mediapipe.dylib
install_name_tool -id mediapipe.dylib mediapipe.dylib
Copied bazel-bin/mediapipe/dylib/mediapipe.dylib to my project
During build I get linking errors:
Undefined symbols for architecture x86_64:
"mediapipe::CalculatorGraph::Initialize(mediapipe::CalculatorGraphConfig const&)", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
MediaPipeApp::setup() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::WaitUntilDone()", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::CloseInputStream(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::AddOutputStreamPoller(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::AddPacketToInputStream(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, mediapipe::Packet&&)", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::StartRun(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mediapipe::Packet, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mediapipe::Packet> > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mediapipe::Packet, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mediapipe::Packet> > > const&)", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::CalculatorGraph()", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
MediaPipeApp::setup() in MediaPipeApp.cpp.o
"mediapipe::CalculatorGraph::~CalculatorGraph()", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
MediaPipeApp::setup() in MediaPipeApp.cpp.o
"mediapipe::internal::OutputStreamPollerImpl::Next(mediapipe::Packet*)", referenced from:
mediapipe::PrintHelloWorld() in MediaPipeApp.cpp.o
ld: symbol(s) not found for architecture x86_64

Try using xcode 11 beta 4 or higher.
Apple moved swift libraries into "swift-5.0" directory, hence tulsi fails to build.
A workaround would be soft-linking the libraries from "swift-5.0" to the "swift" directory and then re-run the build process.
refer to https://forums.developer.apple.com/thread/120074.

Related

dyld: Library not loaded: #rpath/Charts.framework/Chart Reason: image not found Xcode 9.1 Crashes at Runtime

I am getting following error.Please help if anyone is having an idea.I have tried all the solutions but still facing same error.
dyld: Library not loaded: #rpath/Charts.framework/Charts
Referenced from: /Users/adaptteq2017/Library/Developer/CoreSimulator/Devices/18393604-6D9B-4427-85A2-E0DB4F71DF0D/data/Containers/Bundle/Application/7FE7854D-35F1-4DE4-9049-DA7D936A903F/ezSchool.app/ezSchool
Reason: image not found
Facing the same issue.
Follow this process:
Remove the Chart frame work..
Check Chart Framework add in General-> Embedded Binaries + --> ChartFramework.
Add ChartFrame Work in General-> LinkedFrameworks
Build Phase--> Click on + --> Copy File select FrameWork
Add Chart.FrameWork in it.
Clean n Build.
It Works for me.

Undefined symbols for architecture armv7 in Xcode 7.1

I'm making a game with Vuforia and an Unity plugin called Mobile Movie Textures. When I try to build my Xcode project it all goes well until it starts linking. I get a bunch of errors all from the same library saying that it doesn't recognize symbols.
Undefined symbols for architecture armv7:
"_oc_idct8x8_arm", referenced from:
_oc_state_frag_recon_arm in libtheorawrapper.a(armstate.o)
_oc_state_accel_init_arm in libtheorawrapper.a(armstate.o)
"_oc_idct8x8_1_arm", referenced from:
_oc_state_frag_recon_arm in libtheorawrapper.a(armstate.o)
"_oc_frag_recon_intra_arm", referenced from:
_oc_state_frag_recon_arm in libtheorawrapper.a(armstate.o)
_oc_state_accel_init_arm in libtheorawrapper.a(armstate.o)
"_oc_pack_read1_arm", referenced from:
_th_decode_packetin in libtheorawrapper.a(decode.o)
_oc_huff_tree_unpack in libtheorawrapper.a(huffdec.o)
_oc_quant_params_unpack in libtheorawrapper.a(dequant.o)
"_oc_frag_recon_inter2_arm", referenced from:
_oc_state_frag_recon_arm in libtheorawrapper.a(armstate.o)
_oc_state_accel_init_arm in libtheorawrapper.a(armstate.o)
"_oc_frag_copy_list_arm", referenced from:
_oc_state_accel_init_arm in libtheorawrapper.a(armstate.o)
"_oc_frag_recon_inter_arm", referenced from:
_oc_state_frag_recon_arm in libtheorawrapper.a(armstate.o)
_oc_state_accel_init_arm in libtheorawrapper.a(armstate.o)
"_oc_loop_filter_frag_rows_arm", referenced from:
_oc_state_accel_init_arm in libtheorawrapper.a(armstate.o)
"_oc_huff_token_decode_arm", referenced from:
_th_decode_packetin in libtheorawrapper.a(decode.o)
_oc_sb_run_unpack in libtheorawrapper.a(decode.o)
"_oc_pack_read_arm", referenced from:
_th_decode_packetin in libtheorawrapper.a(decode.o)
_oc_sb_run_unpack in libtheorawrapper.a(decode.o)
_th_decode_headerin in libtheorawrapper.a(decinfo.o)
_oc_unpack_length in libtheorawrapper.a(decinfo.o)
_oc_huff_tree_unpack in libtheorawrapper.a(huffdec.o)
_oc_quant_params_unpack in libtheorawrapper.a(dequant.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I could just make the devices with an armv7 arch incompatible but they make up 55% of the dutch market.
I don't know how to fix this, can any of you figure it out?
The library libtheorawrapper.a in the current version of the plugin is broken and does not contains all of the needed symbols.
If you want to use the plugin you will have to recompile the library.
To do that you need to checkout this repository
.
Then edit this file:
MMTPlugin/build/XCode/theorawrapper.xcodeproj/project.pbxproj
an replace on line 134 and 144
/Users/dan/Documents/MobileMovieTexture/
with the path you cloned the repo (eg.):
/Users/MyUser/Code/git/MobileMovieTexture
You can then open that project with XCode and recompile the library.
The resulting file will be placed at:
MMTUnity/Assets/Plugins/iOS/libtheorawrapper.a
you should copy that file to your unity plugin folder:
Assets/Plugins/iOS/libtheorawrapper.a
I got the same issue this morning, it's a problem with the latest version of the MMT plugin: basically, the Assets/Plugins/iOS/libtheorawrapper.a file does not contain everything it should for the armv7 architecture. I replaced it with the same file from the previous version of the plugin (which, fortunately, I had in another project), and everything builds and links again.
As a side note, that file went from about 300KB before to 1.8MB in the latest version, this too seems kind of wrong to me.
I'm about to email the developer about those problems, but feel free to do it too.
I just had this problem today and it seems that more people do as well.
I succeeded in fixing the library file so that it now works. Just replace it with the one in the Unity/plugins/ios folder
here is a link to download it: https://www.dropbox.com/s/kp8u9ggzw6xxvit/libtheorawrapper.a?dl=0

Using tinyxml2 with a Visual Studio, Visual C++ MFC Application

I'm trying to get accustomed to both MFC development and Visual Studio so I have installed Visual Studio 2012 RC and have created a simple MFC Application. Currently the application is little more than the MFC Wizard generated for me.
I decided I wanted to incorporate an XML Library so I found this one on github. I download the ZIP file with the source code, unzip it and then in Visual Studio I goto the solution explorer, choose my solution, right click and choose "Add" > "Existing Project". I select the project file for the source code and it appears in my Solution Explorer tree.
I test the code compiles and it does. However I'm not quite sure how to use it from my current solution.
I try to use this code in my doc:
#include "../../TinyXML2/leethomason-tinyxml2-a3efec0/tinyxml2.h"
<...snip...>
BOOL LoadDocumentFromXML(const CString& filename) {
CT2CA pszConvertedAnsiString (filename);
std::string s(pszConvertedAnsiString);
tinyxml2::XMLDocument doc(true);
if (tinyxml2::XML_NO_ERROR != doc.LoadFile(s.c_str())) {
return FALSE;
}
return TRUE;
}
However I get this linker error when I try to build the project:
------ Build started: Project: GraphApp, Configuration: Debug Win32 ------
GraphAppDoc.cpp
GraphAppDoc.obj : error LNK2019: unresolved external symbol "public: __thiscall tinyxml2::XMLDocument::XMLDocument(bool)" (??0XMLDocument#tinyxml2##QAE#_N#Z) referenced in function "int __cdecl LoadDocumentFromXML(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?LoadDocumentFromXML##YAHABV?$CStringT#_WV?$StrTraitMFC_DLL#_WV?$ChTraitsCRT#_W#ATL#####ATL###Z)
GraphAppDoc.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall tinyxml2::XMLDocument::~XMLDocument(void)" (??1XMLDocument#tinyxml2##UAE#XZ) referenced in function "int __cdecl LoadDocumentFromXML(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?LoadDocumentFromXML##YAHABV?$CStringT#_WV?$StrTraitMFC_DLL#_WV?$ChTraitsCRT#_W#ATL#####ATL###Z)
GraphAppDoc.obj : error LNK2019: unresolved external symbol "public: int __thiscall tinyxml2::XMLDocument::LoadFile(char const *)" (?LoadFile#XMLDocument#tinyxml2##QAEHPBD#Z) referenced in function "int __cdecl LoadDocumentFromXML(class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?LoadDocumentFromXML##YAHABV?$CStringT#_WV?$StrTraitMFC_DLL#_WV?$ChTraitsCRT#_W#ATL#####ATL###Z)
C:\Users\Phill\Documents\Visual Studio 2012\Projects\GraphApp\Debug\GraphApp.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
In the solution explorer I select my MFC application project, right click and choose "Dependencies". I make sure the MFC app is set to be dependent on tinyxml project and I ensure the "Build Order" is correct (tinyxml first). I also goto into "References..." and add tinyxml there too. I even add the debug directory of tinyxml to my MFC app's include path in project properties as well. What am I missing please?
Ok it turns out I didn't read the documentation fully. Reading the XML attached the project here states:
It is one header and one cpp file. Simply add these to your project
and off you go.
So I did this. Then I got some compiler warnings:
------ Build started: Project: GraphApp, Configuration: Debug Win32 ------
tinyxml2.cpp
c:\users\phill\documents\visual studio 2012\projects\graphapp\graphapp\tinyxml2.cpp(24): warning C4627: '#include "tinyxml2.h"': skipped when looking for precompiled header use
Add directive to 'stdafx.h' or rebuild precompiled header
c:\users\phill\documents\visual studio 2012\projects\graphapp\graphapp\tinyxml2.cpp(26): warning C4627: '#include <cstdio>': skipped when looking for precompiled header use
Add directive to 'stdafx.h' or rebuild precompiled header
c:\users\phill\documents\visual studio 2012\projects\graphapp\graphapp\tinyxml2.cpp(27): warning C4627: '#include <cstdlib>': skipped when looking for precompiled header use
Add directive to 'stdafx.h' or rebuild precompiled header
c:\users\phill\documents\visual studio 2012\projects\graphapp\graphapp\tinyxml2.cpp(28): warning C4627: '#include <new>': skipped when looking for precompiled header use
Add directive to 'stdafx.h' or rebuild precompiled header
c:\users\phill\documents\visual studio 2012\projects\graphapp\graphapp\tinyxml2.cpp(29): warning C4627: '#include <cstddef>': skipped when looking for precompiled header use
Add directive to 'stdafx.h' or rebuild precompiled header
c:\users\phill\documents\visual studio 2012\projects\graphapp\graphapp\tinyxml2.cpp(1834): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
So then I selected "tinyxml2.cpp" in the solutions explorer, right clicked, went to properties. In properties under "C++" I went to "Precompiled Headers" and changed the option that read:
Precompiled Header: Use
to
Precompiled Header: Not using precompiled headers
Then it magically worked!

Unable to link in C++/CLI application

I am trying to wrap a C++ class "OpenViBE::Kernel::CPlayer" into a Managed C++ application, so I can later use it in C#.
#include "stdafx.h"
#include "ovkCPlayer.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
const OpenViBE::Kernel::IKernelContext* r=nullptr;
OpenViBE::Kernel::CPlayer* c=new OpenViBE::Kernel::CPlayer(*r);
//c->initialize();
return 0;
}
The above code compiles, it but does not link. The "OpenViBE::Kernel::CPlayer" is in project "OpenViBE-kernel-dynamic". I found where is the lib file from Properties->Linker->Advanced->Import Library. Then I added this folder to the lib path of my project (above) and the "OpenViBE-kernel-dynamic.lib" to the Linker->Input->Additional dependencies.
So the lib file is there, but the linker still can not link it:
error LNK2019: unresolved external symbol "public: __thiscall OpenViBE::Kernel::CPlayer::CPlayer(class OpenViBE::Kernel::IKernelContext const &)" (??0CPlayer#Kernel#OpenViBE##$$FQAE#ABVIKernelContext#12##Z) referenced in function ...
I do not have experience in writing C++/CLI applications, so I think I am missing something.

Undefined symbols for architecture i386: "_AudioServicesCreateSystemSoundID"

I am trying to make a soundboard app and i get this error
Undefined symbols for architecture i386:
"_AudioServicesCreateSystemSoundID", referenced from:
-[S0undFXViewController sound1] in S0undFXViewController.o
-[S0undFXViewController sound2] in S0undFXViewController.o
-[S0undFXViewController sound3] in S0undFXViewController.o
-[S0undFXViewController sound4] in S0undFXViewController.o
-[S0undFXViewController sound5] in S0undFXViewController.o
-[S0undFXViewController sound6] in S0undFXViewController.o
I DONT GET IT!!!!!!!
That sort of error is usually caused by a missing framework.
Have you added the AudioServices framework to your project? It isn't enough to just import the header files.
Edit
Actually, if you turn on module support in Xcode, it is enough to just #import the Framework.

Resources