Sign in to follow this  
ZeMag

SDL and vectors

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this