Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] collect2: error: ld returned 1 exit status #3531

Open
Nacho-Neko opened this issue Jan 15, 2024 · 3 comments
Open

[Build] collect2: error: ld returned 1 exit status #3531

Nacho-Neko opened this issue Jan 15, 2024 · 3 comments
Labels

Comments

@Nacho-Neko
Copy link

Nacho-Neko commented Jan 15, 2024

The error you encountered while using rust-arrayfire is "collect2: error: ld returned 1 exit status." To troubleshoot, you tried manually compiling with GCC using the following command:
gcc -lafcpu -L/opt/arrayfire/lib -I/opt/arrayfire/include -std=c++11 helloworld.cpp.
This also resulted in the same error.

You have installed ArrayFire by compiling it, with the installation path at /opt/arrayfire,
using the command
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/arrayfire.

$LD_LIBRARY_PATH=/opt/arrayfire/lib

ll * /opt/arrayfire
total 28
drwxr-xr-x 7 root root 4096 Jan 15 18:29 ./
drwxr-xr-x 4 root root 4096 Jan 15 18:29 ../
drwxr-xr-x 2 root root 4096 Jan 15 18:29 LICENSES/
drwxr-xr-x 2 root root 4096 Jan 15 19:42 etc/
drwxr-xr-x 3 root root 4096 Jan 15 18:29 include/
drwxr-xr-x 2 root root 4096 Jan 15 19:42 lib/
drwxr-xr-x 3 root root 4096 Jan 15 18:29 share/
root@farm:/opt/arrayfire/share/ArrayFire/examples/helloworld# ll -d /opt/arrayfire
drwxr-xr-x 7 root root 4096 Jan 15 18:29 /opt/arrayfire/
root@farm:/opt/arrayfire/share/ArrayFire/examples/helloworld# ll * /opt/arrayfire
-rw-r--r-- 1 root root 12890 Jan 15 19:48 CMakeCache.txt
-rw-r--r-- 1 root root   796 Jan 15 07:42 CMakeLists.txt
-rw-r--r-- 1 root root  5438 Jan 15 20:18 Makefile
-rw-r--r-- 1 root root  1670 Jan 15 19:48 cmake_install.cmake
-rw-r--r-- 1 root root  1958 Jan 15 07:42 helloworld.cpp
-rwxr-xr-x 1 root root 26528 Jan 15 19:51 helloworld_cpu*

/opt/arrayfire:
total 28
drwxr-xr-x 7 root root 4096 Jan 15 18:29 ./
drwxr-xr-x 4 root root 4096 Jan 15 18:29 ../
drwxr-xr-x 2 root root 4096 Jan 15 18:29 LICENSES/
drwxr-xr-x 2 root root 4096 Jan 15 19:42 etc/
drwxr-xr-x 3 root root 4096 Jan 15 18:29 include/
drwxr-xr-x 2 root root 4096 Jan 15 19:42 lib/
drwxr-xr-x 3 root root 4096 Jan 15 18:29 share/

CMakeFiles:
total 68
drwxr-xr-x 5 root root  4096 Jan 15 20:18 ./
drwxr-xr-x 3 root root  4096 Jan 15 21:48 ../
drwxr-xr-x 3 root root  4096 Jan 15 19:48 3.22.1/
-rw-r--r-- 1 root root   676 Jan 15 19:48 CMakeDirectoryInformation.cmake
-rw-r--r-- 1 root root 24382 Jan 15 19:48 CMakeOutput.log
drwxr-xr-x 2 root root  4096 Jan 15 19:48 CMakeTmp/
-rw-r--r-- 1 root root  2022 Jan 15 20:18 Makefile.cmake
-rw-r--r-- 1 root root  3749 Jan 15 20:18 Makefile2
-rw-r--r-- 1 root root   238 Jan 15 20:18 TargetDirectories.txt
-rw-r--r-- 1 root root    85 Jan 15 20:18 cmake.check_cache
drwxr-xr-x 2 root root  4096 Jan 15 20:18 helloworld_cpu.dir/
-rw-r--r-- 1 root root     2 Jan 15 20:18 progress.marks
@Nacho-Neko
Copy link
Author

When I tried building the examples using cmake, it completed successfully, and I was able to run the build results without any issues.

@Nacho-Neko
Copy link
Author

I believe the key to solving the problem is figuring out how to make my GCC compile successfully.

@FloopCZ
Copy link
Contributor

FloopCZ commented Jan 26, 2024

Try to compile your program using g++ instead of gcc. The former links slightly different libraries by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants