0

My code looks like this

#include <iostream>
#include <SDL2\SDL.h>

int main(int argc, char* args[])
{
    char tep;
    std::cin >> tep;
    return 0;
}

Visual Studio now displays the following error:

LNK1120 2 unresolved externals
LNK2019 reference to unresolved external symbol "_imp_ printf" function in "_ShowError".
LNK2019 reference to unresolved external symbol "_imp_ _iob_func" in function "_ShowError".

I have really already searched many articles about this issue, but either that what it says is true not just my problem, or the solutions are not working.

And if it helps, I have been working on the following video:https://www.youtube.com/watch?v=uzwAYyK9ZBY&feature=iv&src_vid=TC0kHYRWX1Y&annotation_id=annotation_1897517141

Thanks in advance

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
OPT_Developer
  • 43
  • 1
  • 1
  • 5
  • How do you compile & link? BTW, you should really stick to the convention of naming the arguments `argv`. – cadaniluk Oct 04 '15 at 10:08
  • It's not a compile/link problem. VS 2015 deprecated certain functions and SDL won't just compile. I had to compile the source code myself and comment a couple lines so the compiler wouldn't complain. – aslg Oct 04 '15 at 10:11
  • @aslg, How did you du that? – OPT_Developer Oct 04 '15 at 10:34
  • 1
    I wouldn't recommend my solution. At the time I didn't know what to do and the most immediate solution was to comment a certain line. But you can find better solutions [in this question](http://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2) – aslg Oct 04 '15 at 10:49
  • Definitely a dupe. Long story short, always use a version of the library that was built with the same version of toolchain that you're using!! – Lightness Races in Orbit Oct 04 '15 at 12:03

1 Answers1

-1

Try put #undef main before your entry point. I had this exact problem. Try it, and let me know how it goes.

SDL for some reason defines "#define main SDL_main"

So try something like this:

#undef main

int main(int argc, char *args[])

Zebrafish
  • 11,682
  • 3
  • 43
  • 119
  • WOW!!! Thank you very much! – OPT_Developer Oct 04 '15 at 11:51
  • Ehm... this would result in a failure to link `main`, not those `_ShowError` functions. This _can't_ be the fix, if the question is not buggy. – Lightness Races in Orbit Oct 04 '15 at 12:02
  • @TitoneMaurice: Exactly what I said. Logically, this cannot be the fix for the stated problem. Either something is masking the real problem, or something changed to make it seem like this solved the real problem. Analogy: "Help! My cows are all dying!" "Okay try retuning your FM radio to 76.5KHz". "Wow, that worked! Thanks!" Completely unrelated action that implies something else changed in the interim. – Lightness Races in Orbit Oct 04 '15 at 21:48
  • 1
    Yes, maybe it's not the best or the real solution for the problem, but it worked - maybe with a detour, but it worked, and this is the most important! – OPT_Developer Oct 05 '15 at 12:41