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

Author Topic: Error in compilation test project VC8 c++  (Read 3778 times)

0 Members and 1 Guest are viewing this topic.

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Error in compilation test project VC8 c++
« on: February 17, 2014, 07:29:46 pm »
Hi, here as create new project win32. But I have a problem.
Here my step:
File->New->Project Win 32 project
next-> empty project
source(right mouse press) add-> new item main.cpp -> ok

http://sfml-dev.org/tutorials/2.1/start-vc.php

Then (right mouse press) in project -> propereties

All configurations
C++ -> General -> AID(aditional include directores) -> D:\sfml\include
linker -> Generals -> AID ->D:\sfml\lib
Debag
linker-> input additional dependencies->
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
sfml-audio-d.lib

Copy test code in main.cpp:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

ctr+F5
Errors!!! =)

1>------ Build started: Project: sas, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Projects\sas\Debug\sas.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Projects\sas\sas\Debug\BuildLog.htm"
1>sas - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Error in compilation test project VC8 c++
« Reply #1 on: February 17, 2014, 07:32:32 pm »
Quote from the very tutorial you linked...
Quote
If you chose to create a "Windows application" project, then the entry point of your code has to be the "WinMain" function instead of "main". Since it's Windows specific, and your code would therefore not compile on Linux or Mac OS X, SFML provides a way to keep a standard "main" entry point in this case: link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window and sfml-system.

And on top of that I highly suggest upgrading to a newer compiler to take advantage of C++11 features (VC++8 is extremely outdated).  ;)

And by the way, this is not related to CSFML  ::)
« Last Edit: February 17, 2014, 07:50:03 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Error in compilation test project VC8 c++
« Reply #2 on: February 17, 2014, 07:39:11 pm »
Quote from the very tutorial you linked...
Quote
If you chose to create a "Windows application" project, then the entry point of your code has to be the "WinMain" function instead of "main". Since it's Windows specific, and your code would therefore not compile on Linux or Mac OS X, SFML provides a way to keep a standard "main" entry point in this case: link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window and sfml-system.

And on top of that I highly suggest upgrading to a newer compiler to take advantage of C++11 features (VC++8 is extremely outdated).  ;)

In this case - since we are dealing with the C bindings - I guess it would be to take advantage of C99/C11 features (does the MS C compiler actually support any bits of C11? I know their C99 support has been lacking but getting better; but C11??).
(I'm not a Windows person but still currious)


Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Error in compilation test project VC8 c++
« Reply #3 on: February 17, 2014, 07:41:41 pm »
Ohh and by the way; what you've got there is not a compilation error - it's a linking error.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Error in compilation test project VC8 c++
« Reply #4 on: February 17, 2014, 07:46:38 pm »
Please don't double post, there is an edit button  ;)

Quote
In this case - since we are dealing with the C bindings

This is not a C binding issue, for crying out loud - does the code or libs he is trying to link look like C?

Quote
Ohh and by the way; what you've got there is not a compilation error - it's a linking error.

No need to be getting picky with terminology.
« Last Edit: February 17, 2014, 07:50:46 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Re: Error in compilation test project VC8 c++
« Reply #5 on: February 17, 2014, 07:47:05 pm »
In console - complente!
In win32 - error!!! >:(
Using WinMain i me error. Look here:

Code:
#include <SFML/Graphics.hpp>

int WinMain()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Error:

1>------ Build started: Project: sas, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\projects\sas\sas\main.cpp(4) : warning C4007: 'WinMain' : must be '__stdcall'
1>Linking...
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Projects\sas\Debug\sas.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Projects\sas\sas\Debug\BuildLog.htm"
1>sas - 2 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

----------
need example!
Give example pleas!!!
« Last Edit: February 17, 2014, 07:49:22 pm by GalakTozawr »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Error in compilation test project VC8 c++
« Reply #6 on: February 17, 2014, 07:49:16 pm »
#1 Read what I kindly linked you from the tutorial.
#2 Try reading and understanding error messages, this is a vital skill - at least try googling the error message.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Re: Error in compilation test project VC8 c++
« Reply #7 on: February 17, 2014, 07:51:57 pm »
I read Google before creating threads.
Minor bugs I understand, but not those evil!!! >:(

Can screen create?

EXAMPLE Please enter the studio!!!

Or how to make that the console does not display when the program run
« Last Edit: February 17, 2014, 07:57:42 pm by GalakTozawr »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Error in compilation test project VC8 c++
« Reply #8 on: February 17, 2014, 07:58:37 pm »
Quote
author=zsbzsb link=topic=14425.msg101482#msg101482 date=1392662798]
Please don't double post, there is an edit button  ;)

Did I do that? I don't see a double post here - unless you think my two replies should have been one.. Sorry if I should have merged them.

Quote
Quote
In this case - since we are dealing with the C bindings

This is not a C binding issue, for crying out loud - does the code or libs he is trying to link look like C?

Nope. But it was posted in the C bindings forum for some reason, so I just assumed that C was the target that he wanted to discuss.

Quote
Quote
Ohh and by the way; what you've got there is not a compilation error - it's a linking error.

Linking is a sub process of compilation, no need to be getting picky with terminology.

I'm not trying to "get picky", but understanding the difference between errors that occur during pre-processing, compilation, linking and run-time linking/execution can sometimes be critical in quickly figuring out what went wrong. Every competent developer should understand the difference between them and pointing out the specifics is not something I consider "picky".

GalakTozawr

  • Newbie
  • *
  • Posts: 17
  • You must create more game that oneself.
    • View Profile
    • My SFML lesson for russian language
    • Email
Re: Error in compilation test project VC8 c++
« Reply #9 on: February 17, 2014, 08:03:56 pm »
Ah yes, I understand what went wrong, but I do not write correctly comes winMain(). If you are prompted example of the work I would have been easier.