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

Author Topic: No executable ?  (Read 6446 times)

0 Members and 1 Guest are viewing this topic.

Demian

  • Newbie
  • *
  • Posts: 16
    • View Profile
No executable ?
« on: April 15, 2010, 06:00:11 pm »
Hey

I am trying to build some code for my game, but everytime I try to compile it my compiler doesn't create a .exe data.
It's really simple so far:

main.cpp
Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

#include <sstream> // String stream library
#include <iostream>

#include "Game_Board.h"


int main()
{

    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");


    Menue(App);         //Before App.IsOpened() we go visit the Menue

    sf::Image Image;
    sf::Sprite Sprite(Image);


    while (App.IsOpened())
    {

        sf::Event Event;
        while (App.GetEvent(Event))
        {

            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        App.Clear();

        App.Draw(Sprite);


        App.Display();
    }

    return EXIT_SUCCESS;
}


FS_STATES.cpp
Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

#include "Game_Board.h"

int Menue(sf::RenderWindow &App)
{
    Window_State = FS_Menue;    // Window state is set to Menue
    App.Clear();                // Clear the whole Window


    sf::Image IMG_Buttons;      // Create the Image for all buttons

    // After load it's Image in case it fails return back with (!=) 0
    if (!IMG_Buttons.LoadFromFile("Buttons.bmp")
    return EXIT_FAILURE;


    sf::Sprite Button_Start(IMG_Buttons);       // Create the Sprite for Button : Start
    Button_Start.SetPosition(325.f, 150.f);     // Change it's Position

    // Start the Menue loop as long as the Window state contains FS_Menue
    while (Window_State == FS_Menue)
    {
        // Create a Event for the Menue (to handle buttons, clicks etc.)
        sf::Event Menue_Event;
        while (App.GetEvent(Event))         //Event loop for events
        {

            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        App.Clear();

        App.Draw(Button_Start);

        App.Display();
    }

    return EXIT_SUCCESS ;

}



Game_Board.h
Code: [Select]

#ifndef BOARD
#define BOARD

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

#define BOARD_Y_SIZE        //Can be changed    (5-20)
#define BOARD_X_SIZE        //Can be changed    (5-20)


enum Token
{
    Empty,
    Red,
    Blue,
};

// And these, the outline types of the tokens
enum Outline
{
    Normal,
    Highlight
};

// Returned when trying to place a token in a column
//
enum Move
{
    Placed,
    Full,
    EndOfGame

};

// Enum for all possible Window states.
// This Programm just uses Menue, Game, Init and Pause
enum WindowState
{
    FS_Menue,
    FS_Pause,
    FS_Game,
    FS_Init
};

// This template allows you to add a varible to a string in order to print out
template <typename T>
std::string str(const T& x)
{
    std::ostringstream oss;
    oss << x;

    return oss.str();
}

int Window_State = FS_Init; //Holds the state info for the window , starts with "FS_Init"

int Menue(sf::RenderWindow &App);



Compiler post :
Code: [Select]

1. ||Info: resolving vtable for sf::Spriteby linking to __imp___ZTVN2sf6SpriteE |
obj\Debug\FS_STATES.o
2.||In function `_ZNSt8_Rb_treeIPN2sf11ResourcePtrINS0_5ImageEEES4_St9_IdentityIS4_ESt4lessIS4_ESaIS4_EE11_M_put_nodeEPSt13_Rb_tree_nodeIS4_E':|
3.||warning: auto-importing has been activated without --enable-auto-import specified on the command line.|
||=== Build finished: 0 errors, 1 warnings ===|



Thanks to you all : )

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
No executable ?
« Reply #1 on: April 15, 2010, 06:36:34 pm »
It should be in your bin/debug or bin/release folder

Demian

  • Newbie
  • *
  • Posts: 16
    • View Profile
No executable ?
« Reply #2 on: April 15, 2010, 10:01:23 pm »
Quote from: "Ashenwraith"
It should be in your bin/debug or bin/release folder


Yeah I know, but there is no exe ; (
Could it be that I changed something to say the compiler not to build anything.
It's because when i try to use the "build and run" button it always says "It seems that the code isn't build yet.Build it now?"
Then I say yes, it's compiling and there it goes again...no exe and no running it.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
No executable ?
« Reply #3 on: April 15, 2010, 10:20:15 pm »
What compiler are you using? Visual studio?

Make sure you are building an application and not a library. Then, make sure you read the building log. I'm sure there are errors there.

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
No executable ?
« Reply #4 on: April 16, 2010, 04:50:39 am »
If nothing else works you could always start a fresh project and drop your code into it.

coolhome

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
No executable ?
« Reply #5 on: April 16, 2010, 05:06:45 am »
Quote from: "panithadrum"
What compiler are you using? Visual studio?

Make sure you are building an application and not a library. Then, make sure you read the building log. I'm sure there are errors there.


Yeah if its visual studios go to
Project -> Properties -> Config Properties -> General -> Config Type change to Application (.exe)
CoderZilla - Everything Programming

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
No executable ?
« Reply #6 on: April 16, 2010, 09:46:43 am »
compilation : ok
linking : not ok

Seems you have a problem while linking process.
What lib are you using : static or dynamic ?
Are you compiling debug exe with debug (-d) libs ?
If dynamic linking are you usinge the SFML_DYNAMIC define ?
Mindiell
----

Osbios

  • Newbie
  • *
  • Posts: 23
    • View Profile
No executable ?
« Reply #7 on: April 16, 2010, 12:20:55 pm »
What libs do you link to?

If you did not create a console application you also have to link "sfml-main.lib".

Demian

  • Newbie
  • *
  • Posts: 16
    • View Profile
No executable ?
« Reply #8 on: April 16, 2010, 02:42:00 pm »
@Mindiell
No I'm linking the standard libs to compile it :
-lsfml-system
-lsfml-window
-lsfml-graphics

@Coolhome
I'm using code blocks.

In the project options it say :
Output filename : "bin\Debug\SFMLTEST.exe"

@Osbios
I didn't know about that.
I used to build my codes without this and it worked.

@Walker
I did that two times ...it doesn't work after it either

@panithadrum
I will have a look at it

Demian

  • Newbie
  • *
  • Posts: 16
    • View Profile
No executable ?
« Reply #9 on: April 16, 2010, 02:56:48 pm »
Oh the build log seems to be very interesting.
While building it this appears in the log :

Code: [Select]


-------------- Build: Debug in SFMLTEST ---------------

Linking executable: bin\Debug\SFMLTEST.exe
Info: resolving vtable for sf::Spriteby linking to __imp___ZTVN2sf6SpriteE (auto-import)
obj\Debug\FS_STATES.o: In function `_ZNSt8_Rb_treeIPN2sf11ResourcePtrINS0_5ImageEEES4_St9_IdentityIS4_ESt4lessIS4_ESaIS4_EE11_M_put_nodeEPSt13_Rb_tree_nodeIS4_E':
C:/Programme/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_construct.h:(.data+0x0): multiple definition of `_Window_State'
obj\Debug\main.o:C:/Programme/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_construct.h:(.data+0x0): first defined here
C:\Programme\CodeBlocks\MinGW\bin\ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 1 warnings

 


I don't understand this.
I was able to build and run it, but afterwards I created the FS_STATES.cpp and Game_Board.h and added it to the Project this happened

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
No executable ?
« Reply #10 on: April 16, 2010, 03:34:45 pm »
You forgot to define SFML_DYNAMIC, as explained in the tutorial.
Laurent Gomila - SFML developer

Demian

  • Newbie
  • *
  • Posts: 16
    • View Profile
No executable ?
« Reply #11 on: April 16, 2010, 03:56:58 pm »
Quote from: "Laurent"
You forgot to define SFML_DYNAMIC, as explained in the tutorial.


Still the same ; (

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
No executable ?
« Reply #12 on: April 16, 2010, 05:34:17 pm »
Quote from: "Demian"
Quote from: "Laurent"
You forgot to define SFML_DYNAMIC, as explained in the tutorial.


Still the same ; (


I think I might know your prob which is not clearly explained in the tutorial if you are new.

When you set up your linking and everything you can set it up for your project instead of compiler to make sure everything is correct.

Make sure you create a new project, then at the top menu go to Project>>Build Options

Click Release on the left, set all options again, but make sure the Policy: drop menu is 'Use target options only'

After setting all options go back to the menu at the top Build>>Select Target>>Release

Now try Build>>Build and Run and if successful your exe should be in my_project_folder/bin/release

It won't run without a copy of the dlls used in the same folder.

Also, make sure to save your project and close after these steps  because if code::blocks crashes you will lose all your settings (even compiler/editor/etc).

Demian

  • Newbie
  • *
  • Posts: 16
    • View Profile
No executable ?
« Reply #13 on: April 17, 2010, 03:37:09 pm »
Quote from: "Ashenwraith"

I think I might know your prob which is not clearly explained in the tutorial if you are new.

When you set up your linking and everything you can set it up for your project instead of compiler to make sure everything is correct.

Make sure you create a new project, then at the top menu go to Project>>Build Options

Click Release on the left, set all options again, but make sure the Policy: drop menu is 'Use target options only'

After setting all options go back to the menu at the top Build>>Select Target>>Release

Now try Build>>Build and Run and if successful your exe should be in my_project_folder/bin/release

It won't run without a copy of the dlls used in the same folder.

Also, make sure to save your project and close after these steps because if code::blocks crashes you will lose all your settings (even compiler/editor/etc).


Thanks but this doesn't  seem to work.
I figured out  that the problem is probably related to the code I wrote.
When I remove FS_STATES.cpp and Game_Board.h from the project it works(Plus the Menue(App) Command in main.cpp)
Could you all look at my code and tell me if there's anything wrong with it, please?

===========
EDIT:

I think I figured out the problem.
I defined the Window_State in the .h  instead of declaring it.(I know, you can't define variables in .h files)
Everything works.

I have a last question.
I declare an integer in file a.h and define it in b.cpp and use it in another file c.cpp.
(The function is written in c.cpp and used by b.cpp)
I compile it and it works...how can c.cpp work without the definition of the integer?

Thank you all for the help . )

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
No executable ?
« Reply #14 on: April 19, 2010, 03:01:16 pm »
Quote from: "Demian"
@Mindiell
No I'm linking the standard libs to compile it :
-lsfml-system
-lsfml-window
-lsfml-graphics

@Coolhome
I'm using code blocks.

In the project options it say :
Output filename : "bin\Debug\SFMLTEST.exe"

Seems you are trying to use release libs with debug option... not a good idea ;)
Mindiell
----

 

anything