Hello --
I am getting the following error when I try to run the Linux Java Hello World sample on CentOS 7:
[admin@localhost Hello]$ sudo ./run.sh
Initializing Engine...
Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/ABBYY/FREngine12/Bin/libFREngine.Jni.so: libPortLayer.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.abbyy.FREngine.Engine.loadFREngineJNIDllFromFolder(Engine.java:237)
at com.abbyy.FREngine.Engine.loadFREngineJNIDll(Engine.java:187)
at com.abbyy.FREngine.Engine.GetEngineObject(Engine.java:28)
at Hello.loadEngine(Hello.java:41)
at Hello.Run(Hello.java:29)
at Hello.main(Hello.java:21)
These are the steps I've taken to build/run the application:
cd /opt/ABBYY/FREngine12/Samples/Java/Hello
export LD_LIBRARY_PATH="/opt/ABBYY/FREngine12/Bin"
export JDK="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64"
export PATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64:$PATH
sudo ./build.sh
sudo ./run.sh
What's strange is that there is indeed a libPortLayer.so file in the same directory as libFREngine.Jni.so. Both files are located here:
/opt/ABBYY/FREngine12/Bin
Any ideas on what's wrong?
Comments
4 comments
Hi
My idea is that you are running the shell-scripts as root (with sudo),
but are not exporting the environment-variables as root.
Best regards
Koen de Leijer
That was it -- thank you so much!
I was also facing the same problem and I can't find its solution. I have also posted this question in another forum but still can't get a reply from there. Then I asked my friend to help me out with this problem and he shared your post with me. I am also running the shell-script as root. But now I know my problem solution. Thank you Koen de Leijer.
The error indicates that the Java application is unable to load the native shared library (
libFREngine.Jni.so
) because it depends on another library (libPortLayer.so
) that is either missing or not accessible in the current environment.Run the following command to check the current
LD_LIBRARY_PATH
, which specifies where the system should look for shared libraries:echo $LD_LIBRARY_PATH
If the output is blank, it means the environment variable has not been declared.
Follow the steps below to resolve the issue:
Search for
libPortLayer.so
to confirm its location:find / -name libPortLayer.so 2>/dev/null
If
libPortLayer.so
is located in/opt/ABBYY/FREngine12/Bin/
, ensure this path is added to theLD_LIBRARY_PATH
:export LD_LIBRARY_PATH=/opt/ABBYY/FREngine12/Bin:$LD_LIBRARY_PATH
Make this change permanent by adding it to the user's shell configuration file (e.g.,
~/.bashrc
,~/.bash_profile
, or/etc/environment
):echo 'export LD_LIBRARY_PATH=/opt/ABBYY/FREngine12/Bin:$LD_LIBRARY_PATH' >> ~/.bashrc source ~/.bashrc
systemd
, you can configure theLD_LIBRARY_PATH
directly in the service file.sudo nano /etc/systemd/system/your-application.service
Add the environment variable in the
[Service]
section. The updated section should look like this:[Service]
Environment="LD_LIBRARY_PATH=/opt/ABBYY/FREngine12/Bin:/opt/ABBYY/FREngine12/CommonBin/Licensing"
sudo systemctl daemon-reload
sudo systemctl restart your-application
Thanking you!
Please sign in to leave a comment.