Jump to content
  • Advertisement
Sign in to follow this  
Alpha Nox

SDL under VC++ .NET 2003

This topic is 4853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Some people here in the forum told me SDL was a good library for graphics,audio and etc. But I can't use it, it keeps giving linker errors to me when I try to initialize it. I already put the sdl.lib and sdlmain.lib in additional dependecies and the sdl.h header. When I only put the sdl.lib it gives only one error: LIBCMTD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup When I put both or only sdlmain.lib I get: msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) msvcrt.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) msvcrt.lib(MSVCR71.dll) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj) msvcrt.lib(MSVCR71.dll) : error LNK2005: _strncpy already defined in LIBCMTD.lib(strncpy.obj) msvcrt.lib(MSVCR71.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj) msvcrt.lib(MSVCR71.dll) : error LNK2005: __isctype already defined in LIBCMTD.lib(isctype.obj) LINK : warning LNK4031: no subsystem specified; CONSOLE assumed LIBCMTD.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library sdlmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main C:\Documents and Settings\Pedro Aurelio\Meus documentos\Visual Studio Projects\sdltest\Debug\sdltest.exe : fatal error LNK1120: 1 unresolved externals Is it because I'm using Vc++ .NET 2003? Is there a way to fix this? I'm using the following code: #include "stdafx.h" // HAS iosream and string #include <stdlib.h> #include "SDL.h" using namespace std; int main() { if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); system("pause"); return 0; } Thanks, Victor Freire

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
SDL is a multithreaded library and VS defaults to using a single threaded runtime library (incompatable), also SDL overides some default functions.
Project -> Project Preferences -> c/c++ -> Runtime Library ( set this to Multi-threaded (debug) dll).

Share this post


Link to post
Share on other sites
Thanks for your anwser but I am now having this error:


LINK : fatal error LNK1561: entry point must be defined

What's wrong now?

Thanks,

Share this post


Link to post
Share on other sites
I keep with the same error, I tried:

int main() // didnt work

int main(int argc, char **argv) //didnt work

int main(int argc, char *argv[]) // didnt work

int main(int argc, char argv[]) // didnt work

What's wrong???? Why won't it work? Don't I have the main function already?

Thanks again,

Victor Freire

Share this post


Link to post
Share on other sites
I have VC6 so I dont know if it applies but I have to use the old winmain declaration in my SDL apps.

I do it like this:


// Link SDL Libraries
#pragma comment( lib, "SDL.lib" )
#pragma comment( lib, "SDLmain.lib" )

#include <windows.h>
#include <SDL/SDL.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
return 0;
}





Works fine for me, you can link from project settings too instead of using pragmas.


Share this post


Link to post
Share on other sites
Clockwise,

Thanks, it worked fine for me here, but I was trying to make SDL run without windows stuff, I wanted console programming is it possible?

Thanks very much,

Share this post


Link to post
Share on other sites
What kind of console project are you using? It should be a Win32 console project.

If all else fails, follow the link in my signature and go to the 2D Game Tutorials section. It has a tutorial on setting up SDL with VS .NET 2003.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I had the same problem, and this is what did the trick for me.

Go to Project-> Properties-> Linker-> Command Line. Then add this
"/ENTRY:mainCRTStartup" to "additional options".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!