Visual Studio takes two unresolved externals with the linkers LNK2019 [duplicate] - c++

This question already has answers here:
unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2
(19 answers)
Closed 7 years ago.
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

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[])

Related

"Error LNK2001: unresolved external symbol _main" still exists

I know similar question is already been made but none of the answers helped me.
I get this error :
MSVCRT.lib(exe_main.obj) : error LNK2001: unresolved external symbol _main
I am using VS17. I created a Wizard Console Application and a Static Lib.
My A.cpp also looks like this
#include <iostream>
#include "A.h"
namespace img{
int main(int argc, char* argv[]{
...
return 0;
}
}
I tried changing the Properties of the Project as many suggested but everything looks fine.
Main needs to be defined in the global namespace as per conversion.

Linker error LNK2019 on including SDL.h [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 6 years ago.
I'm trying to get my program to allow me to use C++'s input and output streams for debugging purposes but it won't work?
My code:
#include <SDL.h>
#include <iostream>
using namespace std;
int main()
{
cout << "I work!";
return 0;
}
That is all I have and it won't work. I plan to use SDL to make a small checkers game but I'd like to use <iostream> to debug.
Here's my errors:
error LNK2019: unresolved external symbol _SDL_main referenced in function _main_utf8
fatal error LNK1120: 1 unresolved externals
This is covered by FAQ:
Make sure that you are declaring main() as:
int main(int argc, char *argv[])
Since SDL_main is not special name known to C++ compiler, it mangles it by general rules. SDL have forward declaration with correct linking flags (at least extern "C") only for int SDL_main(int, char**).

Unresolved external symbol in a class function [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 6 years ago.
can anyone tell me what is the problem with the following code:
#include <iostream>
#include <string>
using namespace std;
class Exception
{
string err;
public:
Exception (string _err) : err(_err) {}
const string& Err ();
};
int main()
{
Exception exc("error");
cout << exc.Err() << endl;
}
I get unresolved external symbol error on call to the function Exception::Err.
EDIT: Now I see what's the problem, I'm sorry for asking such a stupid question. But I really did spent half an hour looking at the code trying to figure out what's wrong.
Might aswell delete the question to save me from bad reputation. :D And you guys from a bad read. ;)
The error means you didn't define one of your member functions. In this case, you don't have a function body for const string& Err ();

SDL unresolved external symbol

I keep getting these errors:
error LNK2005: _main already defined in main.obj
error LNK2019: unresolved external symbol _SDL_main referenced in function _main_utf8
error LNK1120: 1 unresolved externals
when building this
#include <stdio.h>
#include <SDL.h>
int main(int argc, const char* argv[]){
printf("Hi\n");
return 0;
}
I've set up the directories and the linker in Visual Studio 2013, but I can't figure out what went wrong. I'm using the 32 bit SDL runtime library. I'm also fairly new to C++.
Before your main function, define
#define SDL_MAIN_HANDLED
This stops SDL's "service" of parsing the command line for you(only on windows). Though this is a fix, this isn't good for cross platform programs. The other fix is to change main so that it looks like this:
int main(int argc, char* argv[])
You must do this because of the main macro defined in SDL_Main.h that forces you to have exactly that otherwise it will give you the error you have.

error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup error [duplicate]

This question already has answers here:
error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup, but this time it's NOT a Windows/Console problem!
(4 answers)
Closed 8 years ago.
I am programming SDL in C++ and I keep getting an error:
error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
What can I do to resolve this? Here is my source:
#include <SDL.h>
int main(int argc, char *argv[]){
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* Window = NULL;
Window = SDL_CreateWindow("Render Window",0,0,1000,1000, SDL_WINDOW_SHOWN || SDL_WINDOW_FULLSCREEN);
return 0;
}
My linker and compiler seem fine, I have included console in the subsystem etc. But the error only occurs when I add:
#include <SDL.h>
I think "SDL.h" internally includes "SDL_main.h", which contains a weird #define:
#define main SDL_main
which is almost certainly screwing up your own main.
Try adding #undef main after include "SDL.h", e.g.:
#include <SDL.h>
#undef main
Since you said you have already changed SubSystem to Console, that should be all you need.
See this question for more information.