cannot open shared object file

Skip to first unread message

Alex Shroyer

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:

int main(void) {
    af::array M1 = af::randu(2,4);
    af::array M2 = af::randu(4,1);
    af::array result = af::matmul(M1, M2);

Using this command: 

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: error while loading shared libraries: 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: 

Thanks in advance!

Alex Shroyer

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

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.


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
To view this discussion on the web visit


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/ 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.


Alex Shroyer

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_* --include-subdir --prefix=/home/username/Downloads so that would probably explain the error I saw.
Reply all
Reply to author
0 new messages