watson-intu / self

Intu is a Cognitive Embodiment Middleware for AI on the edge.
Other
29 stars 27 forks source link

Intu does not load libopencv_plugin.dylib from bin/mac/lib/libopencv_plugin.dylib on macOS #25

Closed takaomoriyama closed 7 years ago

takaomoriyama commented 7 years ago

Ivan built and ran Intu on a Mac successfully. Then he made a copy of execution directory under mac/bin on another Mac, and tried to run Intu, but Intu failed to load libopencv_plugin.dylib. Here is a part of the log file. The line number 4 and 5 are showing the case.

[08/10/17 08:19:04.177][STAT][SelfInstance] Loaded platform: ./etc/shared/platforms/mac/platform.json
[08/10/17 08:19:04.179][STAT][SelfInstance] Loaded profile: ./etc/shared/bootstrap.json
[08/10/17 08:19:04.188][STAT][Library] Dynamic library libplatform_mac.dylib loaded.
[08/10/17 08:19:04.188][ERRO][Library] dlerror: dlopen(libopencv_plugin.dylib, 1): image not found
[08/10/17 08:19:04.188][WARN][Library] Failed to load dynamic library libopencv_plugin.dylib.
[08/10/17 08:19:04.197][STAT][Library] Dynamic library librg_plugin.dylib loaded.
[08/10/17 08:19:04.206][STAT][Library] Dynamic library libwatson_plugin.dylib loaded.
[08/10/17 08:19:04.215][STAT][Library] Dynamic library libnexmo_plugin.dylib loaded.
[08/10/17 08:19:04.225][STAT][Library] Dynamic library libiva_plugin.dylib loaded.
[08/10/17 08:19:04.225][ERRO][ISerializable] Failed to find factory for {IObjectRecognition}
[08/10/17 08:19:05.453][STAT][Self] Caught signal: 2, stopping self instance.

I confirmed that this happens on the same machine when I removed build-mac/sdk/lib/libopencv_plugin.dylib. So Intu is not loading libopencv_plugin.dylib from bin/mac/lib/libopencv_plugin.dylib, but from build-mac/sdk/lib/libopencv_plugin.dylib. This can be confirmed by the following steps.

$ git clone git@github.com:takaomoriyama/self-plugins.git                                                                                                       
% cd self                                                                                                                                                       
$ ./scripts/build_mac.sh                                                                                                                                        
...                                                                                                                                                             

$ cd bin/mac                                                                                                                                                    
$ ./run_self.sh                                                                                                                                                 
Running self..                                                                                                                                                  
[08/10/17 08:18:21.107][STAT][SelfInstance] Loaded config: ./config.json                                                                                        
[08/10/17 08:18:21.107][STAT][SelfInstance] Generating new body ID: a1bc211b-28d3-454a-8480-f1d34ee65bb0                                                        
[08/10/17 08:18:21.107][STAT][SelfInstance] Starting SelfInstance                                                                                               
[08/10/17 08:18:21.111][STAT][SelfGraph] Created new model world                                                                                                
[08/10/17 08:18:21.111][STAT][SelfGraph] Graph knowledge loaded (1 verts, 0 edges local)                                                                        
[08/10/17 08:18:21.111][STAT][SelfGraph] Created new model self                                                                                                 
[08/10/17 08:18:21.111][STAT][SelfInstance] Loaded platform: ./etc/shared/platforms/mac/platform.json                                                           
[08/10/17 08:18:21.115][STAT][SelfInstance] Loaded profile: ./etc/shared/bootstrap.json                                                                         
[08/10/17 08:18:21.123][STAT][Library] Dynamic library libplatform_mac.dylib loaded.                                                                            
[08/10/17 08:18:21.130][STAT][Library] Dynamic library libopencv_plugin.dylib loaded.                                                                           
[08/10/17 08:18:21.138][STAT][Library] Dynamic library librg_plugin.dylib loaded.                                                                               
[08/10/17 08:18:21.147][STAT][Library] Dynamic library libwatson_plugin.dylib loaded.                                                                           
[08/10/17 08:18:21.160][STAT][Library] Dynamic library libnexmo_plugin.dylib loaded.                                                                            
[08/10/17 08:18:21.177][STAT][Library] Dynamic library libiva_plugin.dylib loaded.                                                                              
[08/10/17 08:18:21.177][ERRO][ISerializable] Failed to find factory for {IObjectRecognition}                                                                    
^C[08/10/17 08:18:23.300][STAT][Self] Caught signal: 2, stopping self instance.                                                                                 

OK. It successfully started. Then here is error case.

$ mv ../../build-mac/sdk/lib/libopencv_plugin.dylib ../../build-mac/sdk/lib/libopencv_plugin.dylib.save                                                         
$ ./run_self.sh                                                                                                                                                 
Running self..                                                                                                                                                  
[08/10/17 08:39:08.371][STAT][SelfInstance] Loaded config: ./config.json                                                                                        
[08/10/17 08:39:08.371][STAT][SelfInstance] Generating new body ID: 779ba731-ee91-e26e-a79a-282e93441c61                                                        
[08/10/17 08:39:08.371][STAT][SelfInstance] Starting SelfInstance                                                                                               
[08/10/17 08:39:08.373][STAT][SelfGraph] Graph knowledge loaded (2 verts, 0 edges local)                                                                        
[08/10/17 08:39:08.373][STAT][SelfInstance] Loaded platform: ./etc/shared/platforms/mac/platform.json                                                           
[08/10/17 08:39:08.375][STAT][SelfInstance] Loaded profile: ./etc/shared/bootstrap.json                                                                         
[08/10/17 08:39:08.382][STAT][Library] Dynamic library libplatform_mac.dylib loaded.                                                                            
[08/10/17 08:39:08.384][ERRO][Library] dlerror: dlopen(libopencv_plugin.dylib, 1): image not found                                                              
[08/10/17 08:39:08.384][WARN][Library] Failed to load dynamic library libopencv_plugin.dylib.                                                                   
[08/10/17 08:39:08.390][STAT][Library] Dynamic library librg_plugin.dylib loaded.                                                                               
^C[08/10/17 08:39:10.963][STAT][Self] Caught signal: 2, stopping self instance.                                                                                                                                                                                                                                          

A possible fix ight be to add lib/ directory to LD_LIBRARY_PATH as follows:

diff --git a/scripts/mac_scripts/run_self.sh b/scripts/mac_scripts/run_self.sh
index da17fdd..d957a1f 100755
--- a/scripts/mac_scripts/run_self.sh
+++ b/scripts/mac_scripts/run_self.sh
@@ -52,7 +52,7 @@ while true; do

        echo Running self..
        ulimit -c unlimited
-       export LD_LIBRARY_PATH=${SELF_HOME}
+       export LD_LIBRARY_PATH=${SELF_HOME}:${SELF_HOME}/lib
        cd "${SELF_HOME}"
        ./self_instance -P ${PLATFORM} "$@"
        PREV_STATUS="$(echo $?)"
takaomoriyama commented 7 years ago

I created a PR for this. https://github.com/watson-intu/self/pull/26

rlyle commented 7 years ago

PR is merged, closing.

iportilla commented 7 years ago

Thank you Takao & Richard, I appreciate your help with this issue I encountered recently.

The goal of being able to copy ../bin/mac to different laptops was to share the self client to several Mac machines without creating a build on each machine.

rchancey commented 7 years ago

Ivan.. just curious.. why are you trying to zip up the ../bin/Mac director rather than just install it fresh on each Mac? I can think of a few reasons but wanted to see what you are trying to accomplish.