libafcpu.so.3: cannot open shared object file

30 views
Skip to first unread message

Alex Shroyer

unread,
Oct 21, 2021, 9:10:14 PM10/21/21
to ArrayFire Users
On Ubuntu, I downloaded arrayfire to my ~/Downloads folder and tried to compile and run this simple program:

#include<arrayfire.h>
int main(void) {
    af::array M1 = af::randu(2,4);
    af::array M2 = af::randu(4,1);
    af::array result = af::matmul(M1, M2);
    af_print(result);
}

Using this command: 

P=/home/ashroyer/Downloads/arrayfire
g++ main.cpp -std=c++11 -g -I$P/include -L$P/lib64 -lafcpu

It compiles, but when I run I get this error:
./a.out
./a.out: error while loading shared libraries: libafcpu.so.3: cannot open shared object file: No such file or directory

Am I doing something wrong? I also tried the suggestion from this thread, but no change: https://groups.google.com/g/arrayfire-users/c/DkcAJ2_TZv0/m/7TTjfw4CCgAJ 

Thanks in advance!

Alex Shroyer

unread,
Oct 21, 2021, 10:27:50 PM10/21/21
to ArrayFire Users
The question behind this question is how to distribute an application that relies on ArrayFire - is the end-user expected to install the arrayfire libs in /opt?

Pradeep Garigipati

unread,
Oct 22, 2021, 2:12:30 AM10/22/21
to Alex Shroyer, ArrayFire Users
Hello Alex,

Please go through the using ArrayFire on Linux tutorial to understand how to distribute your application for Linux. This process isn't specific to ArrayFire rather it is common practice when shared libraries are involved.


Regards,
Pradeep.

--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/3fafa3f0-fc1d-405d-b3ca-c8e9e66a5650n%40googlegroups.com.


--

uma...@gmail.com

unread,
Oct 22, 2021, 11:36:29 AM10/22/21
to ArrayFire Users
Since you have installed arrayfire in a non-standard location, the operating system loader does not know where to look for the library. You can add the path to LD_LIBRARY_PATH if you want to run something temporarily, you can add a file to /etc/ld.so.conf.d with the path to the arrayfire library, or you can add an rpath to the link command when compiling. Each of these approaches have their benefits and drawbacks so you will have to choose which method works best for your situation.

Umar

Alex Shroyer

unread,
Oct 23, 2021, 2:06:04 PM10/23/21
to ArrayFire Users

Thanks, I installed in /opt/arrayfire to keep things simpler for now. It might have been that I only downloaded but had not yet *installed*. I don't remember running anything like ./Arrayfire_*_Linux_x86_64.sh --include-subdir --prefix=/home/username/Downloads so that would probably explain the error I saw.
Reply all
Reply to author
Forward
0 new messages