1
General / Re: Makefile Help Mac OSX
« on: March 12, 2014, 04:11:22 pm »
I should have mentioned I'm running Mac OS X 10.8.5 on a 2 Ghz Intel Core 2 Duo Macbook with SFML 2.1. I installed everything related to SFML in the standard locations using the included install.sh script.
In my Xcode project, which runs fine, I've made sure to include the following headers:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
I tweaked my Makefile based on an example I found here as follows (I'm not actually using the paths as defined on the first 3 lines, do I need to since everything is in the standard location?):
I'm still getting the following errors when trying to compile my main program. I'm at a loss, can any kind soul point me in the right direction? Is there any obvious reason why sf::Font::loadFromFile, sf::String::String, and sf::Texture::loadFromFile wouldn't be found? I dumped all of my actual fonts and graphics resources right in the same directory as my .cpp, .hpp, and Makefile. Is there a different way I should deal with resources? Thanks
In my Xcode project, which runs fine, I've made sure to include the following headers:
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
I tweaked my Makefile based on an example I found here as follows (I'm not actually using the paths as defined on the first 3 lines, do I need to since everything is in the standard location?):
# paths on MAC OSX
SFML_LIB = -I/usr/local/lib
SFML_INCLUDE = -I/usr/local/include
SFML_FRAMEWORKS = -I/Library/Frameworks
LIBS=-lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network
CXX = g++
CXXFLAGS = -std=c++11
all: battleship
%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
%.o: %.hpp
$(CXX) -c $< -o $@
battleship: BattleshipGUI_Driver.o Button.o GameBoard.o Ship.o Battleship_AI.o
@echo "** Building the game"
$(CXX) -o battleship BattleshipGUI_Driver.o Button.o GameBoard.o Ship.o Battleship_AI.o $(LIBS)
clean:
@echo "** Removing object files and executable..."
rm -f battleship *.o
install:
@echo '** Installing...'
cp battleship /usr/bin/
uninstall:
@echo '** Uninstalling...'
$(RM) /usr/bin/battleship
SFML_LIB = -I/usr/local/lib
SFML_INCLUDE = -I/usr/local/include
SFML_FRAMEWORKS = -I/Library/Frameworks
LIBS=-lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network
CXX = g++
CXXFLAGS = -std=c++11
all: battleship
%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
%.o: %.hpp
$(CXX) -c $< -o $@
battleship: BattleshipGUI_Driver.o Button.o GameBoard.o Ship.o Battleship_AI.o
@echo "** Building the game"
$(CXX) -o battleship BattleshipGUI_Driver.o Button.o GameBoard.o Ship.o Battleship_AI.o $(LIBS)
clean:
@echo "** Removing object files and executable..."
rm -f battleship *.o
install:
@echo '** Installing...'
cp battleship /usr/bin/
uninstall:
@echo '** Uninstalling...'
$(RM) /usr/bin/battleship
I'm still getting the following errors when trying to compile my main program. I'm at a loss, can any kind soul point me in the right direction? Is there any obvious reason why sf::Font::loadFromFile, sf::String::String, and sf::Texture::loadFromFile wouldn't be found? I dumped all of my actual fonts and graphics resources right in the same directory as my .cpp, .hpp, and Makefile. Is there a different way I should deal with resources? Thanks
g++ -c BattleshipGUI_Driver.cpp -std=c++11 -o BattleshipGUI_Driver.o
g++ -c Button.cpp -std=c++11 -o Button.o
g++ -c GameBoard.cpp -std=c++11 -o GameBoard.o
g++ -c Ship.cpp -std=c++11 -o Ship.o
g++ -c Battleship_AI.cpp -std=c++11 -o Battleship_AI.o
** Building the game
g++ -o battleship BattleshipGUI_Driver.o Button.o GameBoard.o Ship.o Battleship_AI.o -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network
Undefined symbols for architecture x86_64:
"sf::Font::loadFromFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
_main in BattleshipGUI_Driver.o
"sf::String::String(char const*, std::locale const&)", referenced from:
_main in BattleshipGUI_Driver.o
"sf::String::String(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::locale const&)", referenced from:
_main in BattleshipGUI_Driver.o
"sf::Texture::loadFromFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)", referenced from:
_main in BattleshipGUI_Driver.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [battleship] Error 1
g++ -c Button.cpp -std=c++11 -o Button.o
g++ -c GameBoard.cpp -std=c++11 -o GameBoard.o
g++ -c Ship.cpp -std=c++11 -o Ship.o
g++ -c Battleship_AI.cpp -std=c++11 -o Battleship_AI.o
** Building the game
g++ -o battleship BattleshipGUI_Driver.o Button.o GameBoard.o Ship.o Battleship_AI.o -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network
Undefined symbols for architecture x86_64:
"sf::Font::loadFromFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
_main in BattleshipGUI_Driver.o
"sf::String::String(char const*, std::locale const&)", referenced from:
_main in BattleshipGUI_Driver.o
"sf::String::String(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::locale const&)", referenced from:
_main in BattleshipGUI_Driver.o
"sf::Texture::loadFromFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, sf::Rect<int> const&)", referenced from:
_main in BattleshipGUI_Driver.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [battleship] Error 1