Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED]Error  (Read 1172 times)

0 Members and 1 Guest are viewing this topic.

floppa_dev

  • Newbie
  • *
  • Posts: 11
    • View Profile
[SOLVED]Error
« on: January 11, 2023, 01:56:34 pm »
I have this errors:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./lib//libsfml-graphics.a when searching for -lsfml-graphics
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./lib/\libsfml-graphics.a when searching for -lsfml-graphics
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./lib//libsfml-window.a when searching for -lsfml-window
(there are others)
and this makefile:
CC = g++
CFLAGS=-O1 -Wall -std=c++17 -Wno-missing-braces -I ./include/ -L ./lib/ -lsfml-graphics -lsfml-window -lsfml-system
SOURCES = src/main.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = floppa

all: $(SOURCES) $(EXECUTABLE)
   
$(EXECUTABLE): $(OBJECTS)
        $(CC) $(CFLAGS) $(OBJECTS) -o $@

.cpp.o:
        $(CC) $(CFLAGS) $< -o $@
 
helppppppppppp
« Last Edit: January 18, 2023, 01:33:24 pm by floppa_dev »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Error
« Reply #1 on: January 11, 2023, 05:05:04 pm »
Make sure the architecture matches, i.e. don't use 32-bits libraries if you build a 64-bits application
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

floppa_dev

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Error
« Reply #2 on: January 12, 2023, 03:13:23 pm »
i fixed it somehow, but now the window crashes instantly
heres the code:

#include <SFML/Graphics.hpp>
#include <cmath>
using namespace sf;
const float PI = 3.14159265358979323846;

// Struct to represent an object with a position, angle, sprite, and texture
struct Object
{
    sf::Vector2f position;
    float angle;
    sf::Sprite sprite;
    sf::Texture texture;
};

// Function to move the object by a specified distance at the specified angle
void moveObject(Object &object, float distance, float angle)
{
    // Calculate the displacement in the x and y directions
    float dx = distance * cos(angle * PI / 180.0f);
    float dy = distance * sin(angle * PI / 180.0f);

    // Update the object's position
    object.position.x += dx;
    object.position.y += dy;

    // Update the object's sprite position
    object.sprite.setPosition(object.position);
}

int main()
{
    // Create an object at position (0, 0) with an angle of 0 degrees
    Object player = {{0, 0}, 0}, bg{{0, 0}, 0};

    // Load an image for the object's texture
    if (!player.texture.loadFromFile("Images/big-floppa-player.png") || !bg.texture.loadFromFile("Images/bg.jpg"))
    {
        return -1;
    }

    // Set the object's texture for the sprite
    player.sprite.setTexture(player.texture);
    bg.sprite.setTexture(bg.texture);
    RenderWindow window(sf::VideoMode(500, 500), "Super Floppa", Style::Fullscreen);
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed || Mouse::isButtonPressed(Mouse::Right))
                window.close();
            //  moveObject(object, 10, 45);
            window.draw(bg.sprite);
            window.draw(player.sprite);
            if (Keyboard::isKeyPressed(Keyboard::A))
                player.position += {-1.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::D))
                player.position += {1.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::W))
                player.position += {0.f, -1.f};
            if (Keyboard::isKeyPressed(Keyboard::S))
                player.position += {0.f, 1.f};
            window.draw(player.sprite);
            window.display();
        }


        return 0;
    }
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Error
« Reply #3 on: January 12, 2023, 03:18:26 pm »
Define "crash".

Use your debugger to see what is going on.
Web search the error message you're getting.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Error
« Reply #4 on: January 12, 2023, 06:01:34 pm »
It could be the textures failing to load as you're checking them and closing the window if they fail.

Try adding a message there and check its output. If its output is also being closed, you could delay the return after the output.

If the textures are failing, check that they are where you expect them to be, spelled exactly correct, and then consider that the working directory may be different from what you expect. In this case, you could try absolute locations to test to see if that is this case.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything