Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 SDL Problem
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Sun Sep 16, 2012 3:41 pm   Post subject: SDL Problem

So I have been trying to play with SDL since it was another popular graphics library currently available for c++ and they are updating for OpenGL 3.0 support. which is awesome. I have linked other libraries and whatnot before like GLWF but for some reason I cant get SDL to work. I am using Visual Studio 2010 on Windows 7 and here is what I did:

First downloaded SDL Dev Lib for C++

Then I extracted the folder to my C Drive

I then opened Visual Studio

I created a new windows 32 empty console application. Named it batman.

I went to project then properties went into VC++ directories

Then I set the Include as include and libary as library -> X86 bit

I next went under linker input and added the library names SDL.lib and SDLmain.lib

went to test it, however it gave me the error:


code:
1>------ Build started: Project: Tutorial, Configuration: Debug Win32 ------
1>Build started 16/09/2012 4:38:32 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\Tutorial.unsuccessfulbuild".
1>ClCompile:
1>  main.cpp
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>
1>SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main
1>
1>C:\Users\Christian\Documents\Visual Studio 2010\Projects\Tutorial\Debug\Tutorial.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.80
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


It compiles fine however it wont build when it gets to the linker.

Here is my code I used:


c:
#include <SDL.h>

int _main (int argc, char argv[]){


        if (!SDL_Init (SDL_INIT_EVERYTHING) == 1){
                return 0;
        }
       
        system("pause");
        return 0;
}
'

If someone could help I would appreciate anything to try.
Sponsor
Sponsor
Sponsor
sponsor
bl0ckeduser




PostPosted: Sun Sep 16, 2012 9:19 pm   Post subject: Re: SDL Problem

Hi

I've been using SDL for a few years on a variety of platforms but never with Visual Studio,
nevertheless, I'm going to try to help because it's a nice library.

Have you tried using this as your main declaration ?
code:

int main(int argc, char *argv[]) {

SDL can be finnicky about how main is declared.

BTW, your code for checking whether SDL initialized properly seems wrong.
SDL_Init() will return 0 on success [1], so !SDL_Init (SDL_INIT_EVERYTHING) == 1 will be true if it succeeds.

Also, argv should be a vector (pointer or array) of character arrays [2] rather than a character array as you have it.

The use of
code:
system("pause");
is frowned upon for several reasons [3].

code:
#include "SDL.h"
is the recommended include line. [4, 5]

I hope this helps.

[1] http://www.libsdl.org/docs/html/sdlinit.html
[2] http://en.wikipedia.org/wiki/Main_function#C_and_C.2B.2B
[3] http://stackoverflow.com/questions/1107705/systempause-why-is-it-wrong
[4] http://lists.libsdl.org/pipermail/sdl-libsdl.org/2010-August/077263.html
[5] SDL 1.2 example code - http://hg.libsdl.org/SDL/file/fba40d9f4a73/test
copthesaint




PostPosted: Mon Sep 17, 2012 9:23 am   Post subject: Re: SDL Problem

I read your post and I tried what you said and you were defiantly right about the main declaration.

I changed my code to:

C:
#include <SDL.h>

int main (int argc, char *argv[]){


        if (SDL_Init (SDL_INIT_EVERYTHING) == 0){
                return 0;
        }
       
        system("pause");
        return 0;
};


The code complies and builds however it does not run. I get the error:

code:
'Tutorial.exe': Loaded 'C:\Users\Christian\Documents\Visual Studio 2010\Projects\Tutorial\Debug\Tutorial.exe', Symbols loaded.
'Tutorial.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Tutorial.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tutorial.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
The program '[10292] Tutorial.exe: Native' has exited with code -1073741515 (0xc0000135).


And on screen I get the prompt:

code:
The Program can't start because SDL.dll is missing from your computer. Try re-installing the program to fix this problem.
Ultrahex




PostPosted: Mon Sep 17, 2012 10:04 am   Post subject: Re: SDL Problem

that means that the dynamically linked library (linked at runtime) SDL.dll is not on the path. Typically people put in the same folder as the executable (.exe) or modify the path (not sure how this works on windows).
copthesaint




PostPosted: Mon Sep 17, 2012 7:03 pm   Post subject: RE:SDL Problem

Thanks, I feel like an idiot for not checking if I put it in my folder lol.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: