Object.hppg ++文件格式無法識別;治療Object.o作爲鏈接腳本
#ifndef OBJECT_HPP
#define OBJECT_HPP
#include <SFML/Graphics.hpp>
using namespace std;
class Object {
private:
sf::Image image;
public:
float x;
float y;
int width;
int height;
sf::Sprite sprite;
virtual void update();
};
#endif
Object.cpp
void Object::update() {
}
這裏是我的Makefile:
LIBS=-lsfml-graphics -lsfml-window -lsfml-system
all:
@echo "** Building mahgame"
State.o : State.cpp
g++ -c State.cpp
PlayState.o : PlayState.cpp
g++ -c PlayState.cpp
Game.o : Game.cpp
g++ -c Game.cpp
Object.o : Object.cpp
g++ -c Object.cpp
Player.o : Player.cpp
g++ -c Player.cpp
mahgame : Game.o State.o PlayState.o Object.o Player.o
g++ -o mahgame Game.o State.o PlayState.o Object.o Player.o $(LIBS)
#g++ -c "State.cpp" -o State.o
#g++ -c "PlayState.cpp" -o PlayState.o
#g++ -c "Game.cpp" -o Game.o
#g++ -c "Object.hpp" -o Object.o
#g++ -c "Player.hpp" -o Player.o
#g++ -o mahgame Game.o State.o PlayState.o Object.o Player.o $(LIBS)
clean:
@echo "** Removing object files and executable..."
rm -f mahgame
install:
@echo '** Installing...'
cp mahgame /usr/bin
uninstall:
@echo '** Uninstalling...'
rm mahgame
這裏是我得到時錯誤建設(建設後,這是一個鏈接器錯誤):
/usr/bin/ld:Object.o: file format not recognized; treating as linker script
/usr/bin/ld:Object.o:1: syntax error
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
想知道發生了什麼?提前致謝。
這不是一個makefile,這個例子不完整,我真的懷疑它是最小的。 – Beta