Makefile doesn't appear to be able to locate compiled lib file, on local machine !?
Attempting to link "/usr/local/Cellar/sfml/2.5.1_1/lib/llibsfml-graphics.2.5.1.dylib" library, however, linker is not able to locate !?
## Binary
BIN := Entity-Simulation
## Compiler
CXX := g++
CXX_FLAGS := -std=c++11
## Directories
SRC_DIRS := ./include
## Linker
LD_FLAG := -L/usr/local/Cellar/sfml/2.5.1_1/lib
LIBS := -lsfml-graphics.2.5.1
# Files
SRCS := $(shell find $(SRC_DIRS) -name '*.hpp')
OBJS := $(patsubst %.hpp, %.o, $(SRCS))
# COMMANDS
## All
all: $(BIN)
## Binary
$(BIN): $(OBJS) main.cpp
touch $@
$(CXX) $(LD_FLAG) $(CXX_FLAGS) main.cpp $(OBJS) -o $@ $(LIBS)
## Objects
%.o: %.hpp
$(CXX) -c $(CXX_FLAGS) $< -o $@
## Clean
clean:
rm -f $(OBJS)
rm -f $(BIN)
g++ -c -std=c++11 include/headers.hpp -o include/headers.o
g++ -c -std=c++11 include/config.hpp -o include/config.o
g++ -c -std=c++11 include/simulation/simulation.hpp -o include/simulation/simulation.o
g++ -c -std=c++11 include/utilities/renderer/SFML_utilities.hpp -o include/utilities/renderer/SFML_utilities.o
g++ -c -std=c++11 include/utilities/specific/step_colors.hpp -o include/utilities/specific/step_colors.o
g++ -c -std=c++11 include/utilities/general/uniform_grid.hpp -o include/utilities/general/uniform_grid.o
g++ -c -std=c++11 include/utilities/general/scale.hpp -o include/utilities/general/scale.o
g++ -c -std=c++11 include/utilities/general/RNG.hpp -o include/utilities/general/RNG.o
g++ -c -std=c++11 include/utilities/general/display.hpp -o include/utilities/general/display.o
g++ -c -std=c++11 include/common/math/math.hpp -o include/common/math/math.o
g++ -c -std=c++11 include/common/structs/general/angle.hpp -o include/common/structs/general/angle.o
g++ -c -std=c++11 include/common/structs/general/point.hpp -o include/common/structs/general/point.o
g++ -c -std=c++11 include/common/structs/general/matrix.hpp -o include/common/structs/general/matrix.o
g++ -c -std=c++11 include/common/structs/general/cell.hpp -o include/common/structs/general/cell.o
g++ -c -std=c++11 include/common/structs/general/color.hpp -o include/common/structs/general/color.o
g++ -c -std=c++11 include/common/structs/custom/attributes.hpp -o include/common/structs/custom/attributes.o
g++ -c -std=c++11 include/common/structs/custom/entity.hpp -o include/common/structs/custom/entity.o
g++ -c -std=c++11 include/common/static/colors.hpp -o include/common/static/colors.o
g++ -c -std=c++11 include/common/static/states.hpp -o include/common/static/states.o
touch Entity-Simulation
g++ -L/usr/local/Cellar/sfml/2.5.1_1/lib -std=c++11 main.cpp ./include/headers.o ./include/config.o ./include/simulation/simulation.o ./include/utilities/renderer/SFML_utilities.o ./include/utilities/specific/step_colors.o ./include/utilities/general/uniform_grid.o ./include/utilities/general/scale.o ./include/utilities/general/RNG.o ./include/utilities/general/display.o ./include/common/math/math.o ./include/common/structs/general/angle.o ./include/common/structs/general/point.o ./include/common/structs/general/matrix.o ./include/common/structs/general/cell.o ./include/common/structs/general/color.o ./include/common/structs/custom/attributes.o ./include/common/structs/custom/entity.o ./include/common/static/colors.o ./include/common/static/states.o -o Entity-Simulation -llibsfml-graphics.2.5.1 -v
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -munwind-tables -target-sdk-version=12.1 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 711 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -std=c++11 -fdeprecated-macro -fdebug-compilation-dir "/Users/justinbyrne/Programs/Xcode/Entity Simulation/Entity Simulation" -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+nullptrToBoolConversion -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNeonImmediateRangeCheck -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+revert09abecef7bbf -mllvm -disable-aligned-alloc-awareness=1 -mllvm -enable-dse-memoryssa=0 -o /var/folders/py/12nv2qy16qn9sgdw6d75bgg00000gn/T/main-c59e7a.o -x c++ main.cpp
clang -cc1 version 13.0.0 (clang-1300.0.29.30) default target x86_64-apple-darwin20.5.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 12.1 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o Entity-Simulation -L/usr/local/Cellar/sfml/2.5.1_1/lib -L/usr/local/lib /var/folders/py/12nv2qy16qn9sgdw6d75bgg00000gn/T/main-c59e7a.o ./include/headers.o ./include/config.o ./include/simulation/simulation.o ./include/utilities/renderer/SFML_utilities.o ./include/utilities/specific/step_colors.o ./include/utilities/general/uniform_grid.o ./include/utilities/general/scale.o ./include/utilities/general/RNG.o ./include/utilities/general/display.o ./include/common/math/math.o ./include/common/structs/general/angle.o ./include/common/structs/general/point.o ./include/common/structs/general/matrix.o ./include/common/structs/general/cell.o ./include/common/structs/general/color.o ./include/common/structs/custom/attributes.o ./include/common/structs/custom/entity.o ./include/common/static/colors.o ./include/common/static/states.o -llibsfml-graphics.2.5.1 -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -llibsfml-graphics.2.5.1
Try to understand how to (either) link to a pre-compiled *.dylib file, or create my own with the lib *.hpp files, and then link
Forgot to include -lsfml-system.2.5.1
and -lsfml-window.2.5.1
to my LIBS
variable... meow everything compiles correctly.
Changed:
LIBS := -lsfml-graphics.2.5.1
to
LIBS := -lsfml-graphics.2.5.1 -lsfml-system.2.5.1 -lsfml-window.2.5.1
Many thanks !