🔒 Locked
Has anyone used SDL + std::vectors in VC2005?
Advertisement
Original Post
I posted a thread recently, but was unable to solve my problem. I'm posting this to see if anyone else has ever succesfully used vectors in an SDL-friendly project in VC2005. If not, I'll just give up on using SDL. I believe that vectors can't be used because the Code Generation is set to Multithreaded DLL, but I'm not in any way an expert. Has anyone made this work?
I have, but it was in VC 2003.
Just so you know, there's absolutely no reason using SDL would make vectors not work. I don't know what your problem is, but just for the record it's not SDL or vector.
edit: now that I think of it, does the express edition come with all the right runtimes? I seem to remember people having problems with it not having all combinations. That would mean your problem is the lack of a multithreaded dll runtime, but that you only noticed when were forced to change code generation to work with SDL.
Anyone know which runtimes he's likely to have, and where to get any he doesn't?
edit: now that I think of it, does the express edition come with all the right runtimes? I seem to remember people having problems with it not having all combinations. That would mean your problem is the lack of a multithreaded dll runtime, but that you only noticed when were forced to change code generation to work with SDL.
Anyone know which runtimes he's likely to have, and where to get any he doesn't?
I have a couple projects at home which I'm 99% sure I've compiled since upgrading, and they use std::vector and SDL just fine. I've never heard of STL/SDL incompatibilities, and people have been running VC2005 through it's various alphas, betas, RCs, and final version that I'm sure we would have heard it by now due to the popularity of vectors and SDL. If you want to be a little more specific, we might be able to diagnose the problem.
Either way, I'll try recompiling them tonight under VC2005 (express edition), and I'll post if I have to change anything to get them to compile.
Either way, I'll try recompiling them tonight under VC2005 (express edition), and I'll post if I have to change anything to get them to compile.
Quote:
Original post by rip-off
does your code work with other compilers?
are you _positive_ its not a problem with your code?
if you're not sure, will you post a minimal example that shows this behaviour
Yes, the exact same code starts compiles in VC2003, and the same function that causes the problem compiles in a Console app.
Crap.
Oh well, C# will probably be easier in the long run. :(
Oh well, C# will probably be easier in the long run. :(
My guess is that the SDL library you're linking with was linked against a different runtime library than your project.
You really should post WHAT problems you're having. Compiler errors? Linker errors? Runtime errors? Your computer turned into a microwave? You never actually described the problem, only your attempt at a solution ('vectors and SDL dont mix'), which is bogus.
You really should post WHAT problems you're having. Compiler errors? Linker errors? Runtime errors? Your computer turned into a microwave? You never actually described the problem, only your attempt at a solution ('vectors and SDL dont mix'), which is bogus.
My advice: recompile SDL! I'm very positive that any runtime-related problems stem from the fact that different runtimes have been used (e.g. Multithreaded vs. MT-DLL) and, worse even, different version (e.g. VC7.1 vs. VC8).
I had similar problems with a precompiled library of mine. After recompiling the lib it worked fine, though.
I had similar problems with a precompiled library of mine. After recompiling the lib it worked fine, though.
Were you using VS 2005?
The exact same code works for me in VS 2003. If this helps, std::string works fine.
The exact same code works for me in VS 2003. If this helps, std::string works fine.
Quote:
Original post by Anonymous Poster
Well... My sprite class uses a std::vector. And yet it displays and works fine.
Compiles in - MVS 2005 Express, Code::Blocks - GCC, Dev-Cpp - GCC. GCC wanted to me to fix my custem Error class, but that's not the point...
:(
You didn't have any problems compiling it? Do you happen to remember whether you changed 'Code Generation' to 'Multithreaded DLL'? :P
Well, I didn't post it here because in both other threads about this same problem (one yesterday, one I posted few months ago that I recently found), no one was able to help. This thread was really just to see if I had any hope of ever getting it to work.
Here is the error message, though:
main.obj : error LNK2001: unresolved external symbol __imp___CrtDbgReportW
And here is the thread: Link
Here is the error message, though:
main.obj : error LNK2001: unresolved external symbol __imp___CrtDbgReportW
And here is the thread: Link
Thanks for the tip.
However, I'm not (directly) using that function. I had this problem a while ago, and here is the code I posted in that thread:
However, I'm not (directly) using that function. I had this problem a while ago, and here is the code I posted in that thread:
#include <SDL/SDL.h>#include <vector>void f(){ std::vector<int> v; v.clear();}int main (int argc, char* argv[]){ return 0;}
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement