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

Fail to compile: ld.lld: error: unable to find library -lstdc++ #3557

Closed
CanYing0913 opened this issue Aug 1, 2024 · 4 comments
Closed

Fail to compile: ld.lld: error: unable to find library -lstdc++ #3557

CanYing0913 opened this issue Aug 1, 2024 · 4 comments

Comments

@CanYing0913
Copy link

Hello HIP community. I have a simple Makefile with my HIP program converted by using hifipy-clang tool:

# Define compiler and compiler flags
CXX = g++
HIPCC = hipcc
SRCS = src
HIPCCFLAGS = -O3 -I /usr/include/x86_64-linux-gnu/c++/11 -I /usr/include/c++/11 -L /usr/lib/x86_64-linux-gnu -v
HIPOBJS = main_hip.o fdtd3d_gpu_hip.o fdtd3d_texture_hip.o

all: hip

hip: hip_gpu.o hip_main.o hip_texture.o
	$(HIPCC) -o hip_gpu $(HIPOBJS) $(HIPCCFLAGS)

hip_main.o: ${SRCS}/main_hip.cpp
	$(HIPCC) -c ${SRCS}/main_hip.cpp $(HIPCCFLAGS)

hip_gpu.o: ${SRCS}/fdtd3d_gpu_hip.cpp ${SRCS}/fdtd3d_gpu_hip.h
	$(HIPCC) -c ${SRCS}/fdtd3d_gpu_hip.cpp $(HIPCCFLAGS)

hip_texture.o: ${SRCS}/fdtd3d_texture_hip.cpp ${SRCS}/fdtd3d_texture_hip.h
	$(HIPCC) -c ${SRCS}/fdtd3d_texture_hip.cpp $(HIPCCFLAGS)

clean:
	rm hip_gpu *.o 

The output messages can be viewed here:
hip_out.txt
It can be seen that it complains: ld.lld: error: unable to find library -lstdc++
Take a deeper look at the output, it seems that it skips a lot of directories. How can I fix this issue? I'm pretty sure I have required libraries (I installed ROCm following official docs and my build-essentials is up-to-date with sudo apt-get update). Any help is appreciated.

@mangupta
Copy link
Contributor

@CanYing0913 : I think you are missing the libstdc++-11-dev or libstdc++-12-dev package on your system for some reason. Could you try installing it depending on which g++ version you have installed?

@CanYing0913
Copy link
Author

@mangupta Passing the correct library path successfully compiles it. After running it, it said no ROCm compatible device detected. However, I do have a NVIDIA gpu, which I think is also supported by HIP?

@harkgill-amd
Copy link

Hi @CanYing0913, have you added your user to the video and render groups? This can be done with the following command

sudo usermod -a -G render,video $LOGNAME

@taylding-amd
Copy link

Hi @CanYing0913, by default, access to GPU devices and certain system resources is restricted to the root user or specific groups. The command sudo usermod -a -G render,video $LOGNAME is used to add the current user to the render and video groups on a Linux system. The render group is typically used to grant access to the GPU for rendering tasks. Members of this group can access the GPU devices directly, which is essential for applications that require GPU acceleration, such as those using ROCm for compute tasks. The video group is used to manage access to video devices. This is important for applications that may need to perform video processing or utilize video hardware acceleration.

After adding the current user to the groups, you need to reboot the system to make it work. Here is a link to the Rocm quick installation guide, please let me know if you have more questions.

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

No branches or pull requests

5 participants