1
General / Weird linking error on Fedora [not on any other linux I've tried] (Solved)
« on: March 24, 2016, 02:30:44 am »
On Fedora 23 when I try to use the native SFML libraries for my game I get the error while compiling:
I am not using Codeblocks or Eclipse, just editing files and compiling through console. This worked on LInux Mint and Ubuntu but Fedora is having issues. Even if I link to a CMake build of SFML I did recently to try to fix this problem, I get the same exact error. Not sure why. Here is how I compile [Makefile]:
Thanks. Will provide more info if needed.
Quote
[hunter@localhost Winter Wasteland]$ make
** Building the game
g++ -o WinterWasteland src/main.o src/Knife.o src/Player.o src/Snowpile.o src/Tree.o src/Weapon.o src/Snowflake.o -std=c++11 -lsfml-graphics -lsfml-window -lsfml-system
src/main.o: In function `main':
main.cpp:(.text+0x945): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
src/Player.o: In function `Player::Player(sf::Vector2<float>, PlayerDirection, PlayerAimDirection, float, int, int)':
Player.cpp:(.text+0xea): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
src/Snowpile.o: In function `Snowpile::Snowpile(sf::Vector2<float>, int)':
Snowpile.cpp:(.text+0x91): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
src/Tree.o: In function `Tree::Tree(sf::Vector2<float>, int)':
Tree.cpp:(.text+0xfd): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
Tree.cpp:(.text+0x185): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
src/Weapon.o:Weapon.cpp:(.text+0x5d3): more undefined references to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)' follow
src/Weapon.o: In function `Enemy::~Enemy()':
Weapon.cpp:(.text._ZN5EnemyD2Ev[_ZN5EnemyD5Ev]+0x13): undefined reference to `vtable for Enemy'
src/Snowflake.o: In function `Snowflake::Snowflake(sf::Vector2<float>, int, int, sf::Vector2<float>)':
Snowflake.cpp:(.text+0xd5): undefined reference to `sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
collect2: error: ld returned 1 exit status
makefile:31: recipe for target 'winterwasteland' failed
make: *** [winterwasteland] Error 1
I am not using Codeblocks or Eclipse, just editing files and compiling through console. This worked on LInux Mint and Ubuntu but Fedora is having issues. Even if I link to a CMake build of SFML I did recently to try to fix this problem, I get the same exact error. Not sure why. Here is how I compile [Makefile]:
Quote
CXX := g++
CXXFLAGS:=-std=c++11
LIBS= -lsfml-graphics -lsfml-window -lsfml-system
all: winterwasteland
main.o: src/main.cpp
$(CXX) -c $(CXXFLAGS) "src/main.cpp" -o src/main.o
Knife.o: src/Knife.cpp src/Knife.h
$(CXX) -c $(CXXFLAGS) "src/Knife.cpp" -o src/Knife.o
Player.o: src/Player.cpp src/Player.h
$(CXX) -c $(CXXFLAGS) "src/Player.cpp" -o src/Player.o
Snowpile.o: src/Snowpile.cpp src/Snowpile.h
$(CXX) -c $(CXXFLAGS) "src/Snowpile.cpp" -o src/Snowpile.o
Tree.o: src/Tree.cpp src/Tree.h
$(CXX) -c $(CXXFLAGS) "src/Tree.cpp" -o src/Tree.o
Weapon.o: src/Weapon.cpp src/Weapon.h
$(CXX) -c $(CXXFLAGS) "src/Weapon.cpp" -o src/Weapon.o
winterwasteland: src/main.o src/Knife.o src/Player.o src/Snowpile.o src/Tree.o src/Weapon.o src/Snowflake.o
@echo "** Building the game"
$(CXX) -o WinterWasteland src/main.o src/Knife.o src/Player.o src/Snowpile.o src/Tree.o src/Weapon.o src/Snowflake.o $(CXXFLAGS) $(LIBS)
Thanks. Will provide more info if needed.