Jump to content
  • Advertisement
Sign in to follow this  
goonst

Linker Error =(

This topic is 4872 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

Sorry if this ends up being a really dumb question, but I'm having a tuff time trying to figure this error out. Below are the two errors I get when I try to compile. Linking... LIBCD.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Debug/Poker.exe : fatal error LNK1120: 1 unresolved externals My program compiled just fine, but once I added the following line #include <SDL.h> It started doing this. This was the only change to my code. Any help would be much appreciated. -- Goonst

Share this post


Link to post
Share on other sites
Advertisement
I threw SDLmain.lib in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib.

Not sure if the correct way I should be adding this lib though.

Share this post


Link to post
Share on other sites
It's not. Go to your project properties, linker setting and hit the input section. Add SDLmain.lib and SDL.lib to the Additional Dependencies line.

Share this post


Link to post
Share on other sites
Even more linker errors unfortunately =(

Linking...
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 LIBCD.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 LIBCD.lib(typinfo.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _exit already defined in LIBCD.lib(crt0dat.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _strrchr already defined in LIBCD.lib(strrchr.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _fgetc already defined in LIBCD.lib(fgetc.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: _setvbuf already defined in LIBCD.lib(setvbuf.obj)
msvcrt.lib(MSVCR71.dll) : error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj)
LIBCD.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
Debug/Poker.exe : fatal error LNK1120: 1 unresolved externals

Any ideas? I think I may have added setup SDL incorrectly. I threw all the SDL header files in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include and all the lib files in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib

Share this post


Link to post
Share on other sites
SDL defines main() as "int main(int argc, char *argv[])" so make sure your main method matches this otherwise the linker will complain.

Regarding the multiple definition errors, make sure you have your code generation options set to multi-threaded DLL for release build and multi-threaded debug dll for debug builds.

Share this post


Link to post
Share on other sites
You need to change your project properties to match the SDL library runtime, it's Properties | C/C++ | Code Generation | Runtime Library. I believe you want to set it to Multithreaded DLL.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!