質問

I am trying to open sdl2 in my project on Visual C++ 2012 but i keep getting this error:

error LNK1104: cannot open file 'SDL2.lib'

I added the additional libraries and include folder but no luck.. I added the link to the libraries through the linker but i get the same error..

what should i do?

役に立ちましたか?

解決

I'm referencing VS 2010, but I've read before that some people have had errors when using the VC++ Directories in their project properties as opposed to the Linker->General->Additional Library Directories.

Unfortunately, there really isn't much more to do besides making sure the directories are linked properly. There really is only one answer to this question. It also may depend on the download of SDL you chose, are you donwloading the Development Library as opposed to the binary?

他のヒント

Watch this video https://www.youtube.com/watch?v=or1dAmUO8k0.

In summary, you want to add the path include folder here: (configuration properties> C/C++ > General> Additional Include Directories),

and add the path of the lib folder here: (configuration properties> Linker > General> Additional Library Directories)

and finally, link .lib file in: linker > input > Additional Dependencies. enter image description here

It seems like you didn't add your library directory path in VC++ Directories/Library Directories.. You have to link your library directory path (Where you have save you libraries of SDL) in your program. After adding, it will definitely work

I would like to add for others experiencing this problem that its an easy mistake if you are using the Development Library to link to the lib folder. SDL needs you link to either the x86 or x64 folder in the lib folder.

If you run or compile your program before you make those required changes of SDL then you will get this error always.. so first add a c++ file then make those changes and then write something and try to run ..this time it will never give this error

It seems like VS can't find the lib files. There are two ways you can do this. One is to configure the appropriate directories in VS as TwinkleBearDev's article shows. Another is to put the libraries directly where VS would look for them, as my article shows. I don't know if the folders for VS2012 are the same though - might be slightly different.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top