here is what I typed in the terminal:
g++ -g -I/Users/cjm10000/Desktop/7701X/code/include/SFML-2.4.2-osx-clang/include -L/Users/cjm10000/Desktop/7701X/code/include/SFML-2.4.2-osx-clang/lib -l libsfml-graphics.2.4.2.dylib -lsfml-window-d -lsfml-system-d virtual_field.cpp -o virtual_field
I am having trouble with this because it is telling me that that it cant find the libraries which included.
ld: library not found for -llibsfml-graphics.2.4.2.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
here is the whole thing if you need more context:
Carloss-MacBook-Pro:src cjm10000$ g++ -g -I/Users/cjm10000/Desktop/7701X/code/include/SFML-2.4.2-osx-clang/include -L/Users/cjm10000/Desktop/7701X/code/include/SFML-2.4.2-osx-clang/lib -l libsfml-graphics.2.4.2.dylib -lsfml-window-d -lsfml-system-d virtual_field.cpp -o virtual_field
ld: library not found for -llibsfml-graphics.2.4.2.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Not really too sure and I don't have a Mac, so I cannot really test it, but I think you might be able to just drop the dylib file ending and the lib in front and just use that after -l, like you do with the other ones.
Something along the lines of this:
g++ -g -I/Users/cjm10000/Desktop/7701X/code/include/SFML-2.4.2-osx-clang/include -L/Users/cjm10000/Desktop/7701X/code/include/SFML-2.4.2-osx-clang/lib -lsfml-graphics -lsfml-window-d -lsfml-system-d virtual_field.cpp -o virtual_field
Edit
I looked up the section on the man page for ld
, which does the actual linking and it says:
-l namespec
--library=namespecAdd the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a.
On systems which support shared libraries, ld may also search for files other than libnamespec.a. Specifically, on ELF and SunOS systems, ld will search a directory for a library called libnamespec.so before searching for one called libnamespec.a. (By convention, a ".so" extension indicates a shared library.) Note that this behavior does not apply to :filename, which always specifies a file called filename.
So you could have used the format -l:libsfml-graphics.2.4.2.dylib
it seems. Note that this is from the man page of ld running on a GNU/linux system, so they do not mention dylib, as it seems to be a Mac specific file format.