SDL and vectors

Started by
3 comments, last by hmmz 17 years, 5 months ago
Hi y'all :P Was trying to do some stuff and got a problem (that wasted most of my afternoon :( It seams I can't use SDL and vectors or lists. I tryed to, and got a nasty error. Compiling... core.cpp Linking... core.obj : error LNK2001: unresolved external symbol __imp___CrtDbgReportW C:\Documents and Settings\ZeMag\Os meus documentos\Programação\SDL e OpenGL\Go-TicTacToe-v0.2\Debug\Go-TicTacToe-v0.2.exe : fatal error LNK1120: 1 unresolved externals Build log was saved at "file://c:\Documents and Settings\ZeMag\Os meus documentos\Programação\SDL e OpenGL\Go-TicTacToe-v0.2\Go-TicTacToe-v0.2\Debug\BuildLog.htm" Go-TicTacToe-v0.2 - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Not a nice sight :( I'm not shure if it is related to de pushback I made (I read somewhere something about that). If it is a way to go around that litle problem, then please tell me, I kinda like to use vectors and lists and now it seams I can't. Edit: Scratch the lists... those work. Will try to use them instead of vectors. Is there any other container that alows to use indexing?
Advertisement
I don't know anything about SDL, but it seems very strange that a third party library could cause a link error like that.

The error seems to be something to do with the debug runtime. Have you tried compiling with the vector code, but in Release mode? Not that that is much of a solution.

If it really (really) won't work, you could always roll out your own template vector class. I can't think of any other STL containers that will allow for indexing like std::vector.

I'm fairly certain though that there must be a solution to get std::vector working. I've never heard anyone else complain of this.

One thing to bear in mind, although it wouldn't cause this problem, is that unlike std::list, std::vector will (I believe) copy on resize and destruct the original items so if you are using a vector to store classes with dynamic data (SDL or otherwise) you need to write solid assignment and copy constructors for the classes. I don't know if that is relevant.
I don't know what the cause of the error is, but just to reinforce what's already been said, there shouldn't be any reason you can't use vector (or anything else from the standard library) with SDL. There's definitely no need to write your own replacement class.

Wish I could help you with the error, but it looks like it's specific to the platform/IDE that you're using (VC++?), and isn't something I recognize. I'm sure someone will be able to help though.
Could you please give us more information about the build environment (compiler, OS, versions of things, etc) you are using, and any changes you've made to the project settings?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

You need to change the runtime library to the DLL one. Inside project properties under C/C++ and then inside code generation change Runtime library to eithere the normal DLL one or the debug DLL one. I think.

This topic is closed to new replies.

Advertisement