I've been looking for many days I try to work with c++ in the vs code, but I can't link libraries. I've tried using the GCC and MSVC compilers, but I'm a beginner and don't know which way to go. Could you help me link a library with the MSVC compiler?`
MSVC error: "LINK : fatal error LNK1561: entry points must be set", with GCC I get something like that.
MSVC script .bat:
@echo off
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86
) else (
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
) else (
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86
)
)
set compilerflags=/Od /Zi /EHsc /std:c++latest /I include
set linkerflags=/OUT:bin\main.exe
cl.exe %compilerflags% src\*.cpp /link %linkerflags%
del bin\*.ilk *.obj *.pdb
Script C++:
#include <iostream>
#include "../include/SDL.h"
int main(int argc, char *argv[])
{
SDL_Window *window;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"An SDL2 window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_OPENGL);
if (window == NULL)
{
std::cout << "error in create window" << std::endl;
return 1;
}
SDL_Delay(3000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}