Jacahehe Temat założony przez niniejszego użytkownika |
[SFML] Wiele bledow przy zmianie trybu kompilacji » 2014-08-27 13:54:06 Wszystko kompilowalo sie wspaniale w trybie debug. Chcialem jednak zmienic tryb na relese i dostalem milion dziwnych bledow. Co wiecej, po ponownej probie skompilowania debugiem rowniez dostaje takie bledy... Dodalem do projektu projektu jakies dll bo ponoc mialo pomoc, ale nic z tego. Może tutaj mi pomozecie :) kod: fruit.h: #include <iostream> #include <SFML/Graphics.hpp> class gracz;
class fruit { public: int int_fruit_positionX; float int_fruit_positionY; int int_targetY; float int_fruit_speed; int int_what_fruit; sf::Texture texture_fruit; sf::Sprite sprite_fruit; void load( std::vector < fruit > & skrzynia, int & i, float trudnosc ); void set_position( std::vector < fruit > & skrzynia, int & i, sf::RenderWindow & window, int & punkty, int & zycia, sf::Texture & tr1, sf::Texture & tr2, sf::Texture & tr3 ); fruit( sf::Sprite spr, int x = 0, float y = 0, int ty = 0, float s = 0, int w = 0 ); };
fruit.cpp: #include <iostream> #include <SFML/Graphics.hpp> #include "fruit.h"
void fruit::load( std::vector < fruit > & skrzynia, int & i, float trudnosc ) { skrzynia[ i ].int_fruit_positionX =(( std::rand() % 1230 ) + 0 ); skrzynia[ i ].int_fruit_positionY = - 50; skrzynia[ i ].int_targetY = 1100; skrzynia[ i ].int_fruit_speed =( 8 * trudnosc ) / 5; skrzynia[ i ].int_what_fruit =(( std::rand() % 3 ) + 1 ); i++; }
void fruit::set_position( std::vector < fruit > & skrzynia, int & pppp, sf::RenderWindow & window, int & punkty, int & zycia, sf::Texture & tr1, sf::Texture & tr2, sf::Texture & tr3 ) { switch( skrzynia[ pppp ].int_what_fruit ) { case 1: skrzynia[ pppp ].sprite_fruit.setTexture( tr1 ); break; case 2: skrzynia[ pppp ].sprite_fruit.setTexture( tr2 ); break; case 3: skrzynia[ pppp ].sprite_fruit.setTexture( tr3 ); break; } skrzynia[ pppp ].int_fruit_positionY = skrzynia[ pppp ].int_fruit_positionY + skrzynia[ pppp ].int_fruit_speed; skrzynia[ pppp ].sprite_fruit.setPosition( skrzynia[ pppp ].int_fruit_positionX, skrzynia[ pppp ].int_fruit_positionY ); window.draw( skrzynia[ pppp ].sprite_fruit ); }
fruit::fruit( sf::Sprite spr, int x, float y, int ty, float s, int w ) { spr = this->sprite_fruit; x = this->int_fruit_positionX; y = this->int_fruit_positionY; ty = this->int_targetY; s = this->int_fruit_speed; w = this->int_what_fruit; }
main.cpp: #include <SFML/Audio.hpp> #include <SFML/Graphics.hpp> #include <SFML/Window.hpp> #include <SFML/System.hpp> #include <iostream> #include <cstdio> #include <math.h> #include <string> #include "fruit.h"
std::vector < fruit > skrzynia; sf::Vector2i mysz;
int punkty = 0; int zycia = 3;
class gracz { friend void fruit::set_position( std::vector < fruit > & skrzynia, int & i, sf::RenderWindow & window, int & punkty, int & zycia, sf::Texture & tr1, sf::Texture & tr2, sf::Texture & tr3 ); public: int x; int y; sf::Texture grtxr; sf::Sprite grspr; void grwczytaj(); void wyswietl_i_ruszaj( sf::RenderWindow & window ); };
void gracz::grwczytaj() { grtxr.loadFromFile( "gracz.png" ); y = 900; }
void gracz::wyswietl_i_ruszaj( sf::RenderWindow & window ) { mysz = sf::Mouse::getPosition( window ); x = mysz.x; grspr.setTexture( grtxr ); grspr.setPosition( x, y ); window.draw( grspr ); }
int main() { bool bstartgry = false; float szybkoscspadania = 350; float trudnosc = 1; srand( time( NULL ) ); int i = 0; bool koniec = false; sf::Texture tr1; tr1.loadFromFile( "1.png" ); sf::Texture tr2; tr2.loadFromFile( "2.png" ); sf::Texture tr3; tr3.loadFromFile( "3.png" ); sf::RenderWindow window( sf::VideoMode( 1280, 1024 ), "Fallen Apple" ); window.setFramerateLimit( 120 ); window.setMouseCursorVisible( false ); sf::Texture teksturka; teksturka.loadFromFile( "1.png" ); sf::Sprite sprajt; sprajt.setTexture( teksturka ); sf::Font font; font.loadFromFile( "Arial.ttf" ); sf::Text tzycia; char chzycia[ 50 ]; tzycia.setFont( font ); tzycia.setPosition( 1000, 50 ); tzycia.setCharacterSize( 40 ); sf::Text tpkt; char chpkt[ 50 ]; tpkt.setFont( font ); tpkt.setPosition( 1000, 100 ); tpkt.setCharacterSize( 40 ); sf::Text tstart; tstart.setString( "NACISNIJ SPACJE ABY \nZACZAC GRE\n\nESC aby wyjsc" ); tstart.setFont( font ); tstart.setPosition( 100, 200 ); tstart.setCharacterSize( 100 ); sf::Text tkoniec; tkoniec.setString( "Koniec gry! \nWcisnij TAB!" ); tkoniec.setFont( font ); tkoniec.setPosition( 100, 200 ); tkoniec.setCharacterSize( 100 ); fruit::fruit( sprajt, 0, 0, 12, 0, 0 ); gracz gracz1; gracz1.grwczytaj(); while( window.isOpen() ) { window.clear(); if( sf::Keyboard::isKeyPressed( sf::Keyboard::Space ) ) { bstartgry = true; } window.draw( tstart ); if( sf::Keyboard::isKeyPressed( sf::Keyboard::Escape ) ) { window.close(); } window.display(); while( bstartgry == true ) { szybkoscspadania = szybkoscspadania + 1 * trudnosc; if( szybkoscspadania > 360 /( trudnosc * 2 ) ) { skrzynia.push_back( fruit( sprajt, 0, 0, 12, 0, 0 ) ); skrzynia[ i ].load( skrzynia, i, trudnosc ); szybkoscspadania = 0; } if( sf::Keyboard::isKeyPressed( sf::Keyboard::Escape ) ) { window.close(); } if( sf::Mouse::isButtonPressed( sf::Mouse::Left ) ) { skrzynia.push_back( fruit( sprajt, 0, 0, 12, 0, 0 ) ); skrzynia[ i ].load( skrzynia, i, trudnosc ); } window.clear(); gracz1.wyswietl_i_ruszaj( window ); for( int pppp = 0; pppp < skrzynia.size(); pppp++ ) { skrzynia[ pppp ].set_position( skrzynia, pppp, window, punkty, zycia, tr1, tr2, tr3 ); if( skrzynia[ pppp ].int_fruit_positionX + 50 >= gracz1.x && skrzynia[ pppp ].int_fruit_positionX + 50 <= gracz1.x + 200 && skrzynia[ pppp ].int_fruit_positionY + 50 >= gracz1.y && skrzynia[ pppp ].int_fruit_positionY + 50 <= gracz1.y + 80 ) { skrzynia.erase( skrzynia.begin() + pppp ); i--; punkty++; trudnosc = trudnosc + 0.015; } else { if( skrzynia[ pppp ].int_fruit_positionY > skrzynia[ pppp ].int_targetY ) { zycia--; skrzynia.erase( skrzynia.begin() + pppp ); i--; } if( zycia <= 0 ) { koniec = true; while( koniec == true ) { window.clear(); sprintf( chpkt, "Punkty: %i", punkty ); tpkt.setString( chpkt ); window.draw( tpkt ); window.draw( tkoniec ); window.display(); if( sf::Keyboard::isKeyPressed( sf::Keyboard::Escape ) ) { window.close(); } if( sf::Keyboard::isKeyPressed( sf::Keyboard::Tab ) ) { skrzynia.clear(); i = 0; szybkoscspadania = 350; trudnosc = 1; zycia = 3; punkty = 0; bstartgry = false; koniec = false; } } } } } sprintf( chzycia, "Zycia: %i", zycia ); tzycia.setString( chzycia ); window.draw( tzycia ); sprintf( chpkt, "Punkty: %i", punkty ); tpkt.setString( chpkt ); window.draw( tpkt ); window.display(); } } return 0; }
Kod bledu: 1>------ Build started: Project: Nauka C++ i SFML, Configuration: Release Win32 ------ 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Transformable::setPosition(float,float)" (__imp_?setPosition@Transformable@sf@@QAEXMM@Z) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?Default@RenderStates@sf@@2V12@B) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::~Texture(void)" (__imp_??1Texture@sf@@QAE@XZ) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::Texture(void)" (__imp_??0Texture@sf@@QAE@XZ) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Sprite::setTexture(class sf::Texture const &,bool)" (__imp_?setTexture@Sprite@sf@@QAEXABVTexture@2@_N@Z) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(void)" (__imp_??0Sprite@sf@@QAE@XZ) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class sf::Transformable & __thiscall sf::Transformable::operator=(class sf::Transformable const &)" (__imp_??4Transformable@sf@@QAEAAV01@ABV01@@Z) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class sf::Drawable & __thiscall sf::Drawable::operator=(class sf::Drawable const &)" (__imp_??4Drawable@sf@@QAEAAV01@ABV01@@Z) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class sf::Sprite & __thiscall sf::Sprite::operator=(class sf::Sprite const &)" (__imp_??4Sprite@sf@@QAEAAV01@ABV01@@Z) 1>fruit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Sprite::~Sprite(void)" (__imp_??1Sprite@sf@@UAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::setFramerateLimit(unsigned int)" (__imp_?setFramerateLimit@Window@sf@@QAEXI@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::setMouseCursorVisible(bool)" (__imp_?setMouseCursorVisible@Window@sf@@QAEX_N@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class sf::Texture & __thiscall sf::Texture::operator=(class sf::Texture const &)" (__imp_??4Texture@sf@@QAEAAV01@ABV01@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Texture::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class sf::Rect<int> const &)" (__imp_?loadFromFile@Texture@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$Rect@H@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::Texture(class sf::Texture const &)" (__imp_??0Texture@sf@@QAE@ABV01@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Keyboard::isKeyPressed(enum sf::Keyboard::Key)" (__imp_?isKeyPressed@Keyboard@sf@@SA_NW4Key@12@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Font::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?loadFromFile@Font@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::~Font(void)" (__imp_??1Font@sf@@QAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::Font(void)" (__imp_??0Font@sf@@QAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setCharacterSize(unsigned int)" (__imp_?setCharacterSize@Text@sf@@QAEXI@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setFont(class sf::Font const &)" (__imp_?setFont@Text@sf@@QAEXABVFont@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Text::setString(class sf::String const &)" (__imp_?setString@Text@sf@@QAEXABVString@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Text::Text(void)" (__imp_??0Text@sf@@QAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Vector2<int> __cdecl sf::Mouse::getPosition(class sf::Window const &)" (__imp_?getPosition@Mouse@sf@@SA?AV?$Vector2@H@2@ABVWindow@2@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Mouse::isButtonPressed(enum sf::Mouse::Button)" (__imp_?isButtonPressed@Mouse@sf@@SA_NW4Button@12@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(class sf::Sprite const &)" (__imp_??0Sprite@sf@@QAE@ABV01@@Z) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Text::~Text(void)" (__imp_??1Text@sf@@UAE@XZ) 1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) 1>E:\Users\Jaca\Documents\Visual Studio 2010\Projects\fallen apple\Release\Nauka C++ i SFML.exe : fatal error LNK1120: 38 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|