• Advertisement
Sign in to follow this  

Having trouble linking libraries (using SDL)

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

I've some experience programming in C++ but never using third party SDKs or libraries, only those that are the original libraries of the C++ language.

I am trying to learn to program applications using SDL. I just started using it. I'm reading this tutorial http://www.sdltutori...tutorial-basics

[color=#000000][background=rgb(244, 244, 244)]I am using Visual C++ 2010 Express. I have downloaded the runtime library "[/background]SDL-1.2.15-win32.zip" and the development libraries
"SDL-devel-1.2.15-VC.zip".

I extracted the content from the development library and extracted it on the folder "D:\SDL\". I made a new project on my Visual C++ 2010. I selected to make a empty project. I simply wrote a program described in the tutorial. I went to project properties->Configuration Properties->
VC++ Directories->Include Directories->"D:\SDL\Include\".

I set the Include path to the folder where all the SDL headers are placed.

Next, I have to link the SDL.dll, SDL.lib and SDLmain.lib in the project and this is where I am having trouble to get the program to execute.
Here is how I set the path, in the VC++ Directories->Library Directories->"D:\SDL\lib\x86\".

When I build the program, it gave me "LNK 1561, entry point must be defined" error. Although I wrote a .cpp file that has a "main" function.

Then I enter the "lib" folder path to project Properties->Configuration Properties->Linker->Input->Additional Dependencies->"D:\SDL\lib\x86".

but still I am getting the same "LNK 1561, entry point must be defined error"...

Can someone please tell me where do I have to give the address of these three files "SDL.dll", "SDL.lib" and "SDLmain.lib" in the Project properties???

I've tried searching the internet, I tried a lot of things but no help.

Ok, I tried making the same project as a "Console Application" and now I am getting this error with the same configuration....


1>CApp.obj : error LNK2019: unresolved external symbol _SDL_PollEvent referenced in function "public: int __thiscall CApp::OnExecute(void)" (?OnExecute@CApp@@QAEHXZ)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>D:\SDL\My SDL Projects\SDLproject\Debug\SDLproject.exe : fatal error LNK1120: 2 unresolved externals

Waiting for a positive response.

Share this post


Link to post
Share on other sites
Advertisement
You need to go to Linker->Input->Additional Dependencies and add the lib files there (only write their name, no need for full path ie. sdl.lib)
SDL.dll should reside in a place where your exectuable can find it as with any dll: in the application directory, Windows directory, etc...

EDIT: reread you post Additional Dependencies should contain the name of the libraries as I wrote, the libraries path should be entered in Linker->General->Additional Library Directories Edited by CableGuy

Share this post


Link to post
Share on other sites

You need to go to Linker->Input->Additional Dependencies and add the lib files there (only write their name, no need for full path ie. sdl.lib)
SDL.dll should reside in a place where your exectuable can find it as with any dll: in the application directory, Windows directory, etc...

EDIT: reread you post Additional Dependencies should contain the name of the libraries as I wrote, the libraries path should be entered in Linker->General->Additional Library Directories


That is it... that is the confusion that I had.... I need to give the path to the folder in the Linker->General->Addition Library Directories and then give the files names at Linker->Input->Additional Dependencies....

Sometimes such simple things can cause confusions....

So, can you give me a brief difference between a .DLL file and .LIB file...

thanks...

Share this post


Link to post
Share on other sites

So, can you give me a brief difference between a .DLL file and .LIB file...


Files with the .lib extension are called static libraries. They are linked into your application at compile time, meaning they become a part of the executable.

Files with the .dll extension are dynamic libraries. They are not linked into the application and do not become a part of the executable. Instead, they are loaded dynamically at runtime in one of two ways. The most common way is for Windows to load it automatically. For this to happen, you need to link with a special static library called an import library. The import library contains only the information needed for Windows to load the dll when your application starts. That's normally what you do with SDL. SDL.lib is an import library, so you always need to have SDL.dll in your application's directory.

Share this post


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

  • Advertisement