Quick Fix: Remove the rogue comma from the SDL_LIB
variable to fix the linker issue. The corrected line should look like this:SDL_LIB = -L/usr/local/lib -lSDL2 -Wl,-rpath=/usr/local/lib -lSDL2_image
The Problem:
While trying to compile a C++ program that uses SDL2 extension libraries, the user encounters the error "/usr/bin/ld: cannot find : No such file or directory". The user suspects an issue with their Makefile, which includes the line "-lSDL2_image". The user has verified that the Makefile previously worked for other examples.
The Solutions:
Solution 1: Remove Rogue Comma
The problem mentioned in the error message, “/usr/bin/ld: cannot find
SDL_LIB = -L/usr/local/lib -lSDL2 -Wl,-rpath=/usr/local/lib, -lSDL2_image
This comma causes the linker to look for libraries in a non-existent directory with an empty name, resulting in the error. To resolve this issue, remove the comma as follows:
SDL_LIB = -L/usr/local/lib -lSDL2 -Wl,-rpath=/usr/local/lib -lSDL2_image