When running make I get an error

No rule to make target ‘/usr/lib/x86_64-linux-gnu/libSDL2_image.so’, needed by ‘SDL2Test’. Stop.

CMakeFiles/Makefile2:72: recipe for target ‘CMakeFiles/SDL2Test.dir/all’ failed

make[1]: *** [CMakeFiles/SDL2Test.dir/all] Error 2

Makefile:83: recipe for target ‘all’ failed

make: *** [all] Error 2

The code is from the internet: Trenki’s blog, I want to learn how to make CMakeLists.txt
This is the github repository:
GitHub - trenki2/SDL2Test: Show how to use SDL2 with CMake.
Thanks.

It looks like your build had found libSDL2_image.so at one point, but it has since been removed. Did you remove the -dev package for it after the initial configure?

That was the fastest answer I ever received.
When I first ran the application I saw the black screen like it is supposed to show, for a second, but then it closed and never appeared again. I didn’t remove anything.
Thanks.

I ran this line: sudo apt-get install libsdl2-image-dev

which I found online.

Do I have to run it every time?

You shouldn’t have to. It’s not clear how the project found the file and then it disappeared when it the build ran.

I used to get a different error, the cmake … wasn’t working, I wrote here then I found that line on the internet, then I saw your answer, which I can’t find now - but my cmake had begun to work.
So should I keep that line that I found, or should I use something else?

cmake - followed by 2 dots, not three

“Two dots” means “parent directory”. “Three dots” is a path named “…” which probably doesn’t exist.

I mean I wrote cmake followed by two dots, I didn’t write 3 dots like the computer writes.That is not the mistake I am making.

Ok, first I was told to use

You need libsdl-image-dev , SDL2_image-devel , or similar installed (depending on the distro you’re using) to have the SDL2_image headers.

I used sudo apt-get install libsdl2-image-dev, I know very little but I think they are similar. Are they?

Package names differ from distro to distro. Without knowing it’s hard to give specific advice, but giving advice along the lines of “it looks something like this” can avoid a Q/A cycle.

At this point, it’s not really clear what the status of your situation is to me though, so more details as to any problems would help.

Well the context is that I am at an online C++ school, where I am learning C++. I did the final project in Visual C++ and I have to upload it to the school’s VM Linux environment.
They gave us the Trenki’s blog link to see how this environment compatibility should be done for those who choose to use SDL2_image in the project. I will make the CMakeLists.txt myself, but first I want to run this.
I know nothing about the distributor or distribution etc.

Here is the cmake error I used to get:

When I run the project at cmake … I get the following error:

The C compiler identification is GNU 5.5.0

– The CXX compiler identification is GNU 7.5.0

– Check for working C compiler: /usr/bin/cc

– Check for working C compiler: /usr/bin/cc – works

– Detecting C compiler ABI info

– Detecting C compiler ABI info - done

– Detecting C compile features

– Detecting C compile features - done

– Check for working CXX compiler: /usr/bin/g+±7

– Check for working CXX compiler: /usr/bin/g+±7 – works

– Detecting CXX compiler ABI info

– Detecting CXX compiler ABI info - done

– Detecting CXX compile features

– Detecting CXX compile features - done

– Looking for pthread.h

– Looking for pthread.h - found

– Looking for pthread_create

– Looking for pthread_create - not found

– Looking for pthread_create in pthreads

– Looking for pthread_create in pthreads - not found

– Looking for pthread_create in pthread

– Looking for pthread_create in pthread - found

– Found Threads: TRUE

– Found SDL2: /usr/lib/x86_64-linux-gnu/libSDL2.so;-lpthread

CMake Error at /usr/local/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):

Could NOT find SDL2_image (missing: SDL2_IMAGE_LIBRARIES

SDL2_IMAGE_INCLUDE_DIRS)

Call Stack (most recent call first):

/usr/local/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)

cmake/FindSDL2_image.cmake:93 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)

CMakeLists.txt:8 (find_package)

– Configuring incomplete, errors occurred!

See also “/home/workspace/SDL2Test/build/CMakeFiles/CMakeOutput.log”.

See also “/home/workspace/SDL2Test/build/CMakeFiles/CMakeError.log”.

Any help would be much appreciated.
Thanks.

Ah, ok. So you’ll need to get the libsdl2-image-dev package as needed in the Linux environment. If you get a fresh one each time, you’ll need to download it again.