SDL error LNK1120: 1 unresolved externals - c++

am trying to test SDL using this codes :
#include <SDL.h>
int main(int argc, char** argv){
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface * screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
bool IsRuning = true;
Uint32 Start;
SDL_Event Event;
while (IsRuning)
{
Start = SDL_GetTicks();
while (SDL_PollEvent(&Event))
{
switch (Event.type)
{
case SDL_QUIT:
IsRuning = false;
break;
default:
break;
}
}
if(1000/30 > (SDL_GetTicks() - Start))
SDL_Delay(1000/30 > (SDL_GetTicks() - Start));
}
SDL_Quit();
return 0;
}
and am linking this libs :
SDLmain.lib
SDL.lib
OpenGL32.lib
glu32.lib
when am trying to debug it it gives me those errors :-
Warning 1 warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library c:\Users\administrator\documents\visual studio 2010\Projects\TestSDL\TestSDL\MSVCRTD.lib(cinitexe.obj)
Error 2 error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function _redirect_output c:\Users\administrator\documents\visual studio 2010\Projects\TestSDL\TestSDL\SDLmain.lib(SDL_win32_main.obj)
Error 3 error LNK1120: 1 unresolved externals c:\users\administrator\documents\visual studio 2010\Projects\TestSDL\Debug\TestSDL.exe 1
what ma missing here?!!

Probably one of SDLmain.lib or SDL.lib links against msvcrt.lib, which is the MicroSoft Visual C RunTime library. However you're compiling a debug build, and debug builds depend on the debug variant of the runtime library. Those two runtime libraries, they are conflicting.
The solution would be to use specific debug builds of the SDL libraries.

I had the same issue. You need to change the line:
int main(int argc, char** argv)
to
int main(int argc, char* argv)

Related

opencv/visual studio : error LNK2019: unresolved external symbol

I have a problem : error LNK2019: unresolved external symbol [...] referenced in function main
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main(int argc, char * const argv[])
{
cvNamedWindow("P2", CV_WINDOW_AUTOSIZE);
//path to image ex : c:/Users/image.jpg
CvCapture* capture = cvCreateFileCapture("path to image");
IplImage* frame;
while (1) {
frame = cvQueryFrame(capture);
if (!frame) break; cvShowImage("P2", frame); char c = cvWaitKey(0); if (c == 27) break;
}
cvReleaseCapture(&capture); cvDestroyWindow("P2");
return 0;
}
enter image description here
I start my project by following tutorial, the same configuration to use OpenCV with visual Studio and Eclipse but I have the same error.
Probably you're missing to specify input library (project property/link/input).
You don't specify which version of opencv you are using. If you are using openCV 3.1 like me the lib is opencv_world310d.lib for debug and opencv_world310.lib for release. Please check also the bitness of your application. The prebuilt libraries are for 64 bit.

How to connect OpenMPI library to Visual Studio 2015

I need to connect OpenMPI library to Visual Studio 2015. I can't use other liblaries instead of OpenMPI. I setup OpenMPI_v1.6.2-1_win32.exe and specified:
Include Directories: C:\Program Files\OpenMPI_v1.6.2-win32\include
Library Directories: C:\Program Files\OpenMPI_v1.6.2-win32\lib
Additional Dependencies: libmpi.lib
Open MP Support: Yes
When I try to compile the code:
#include <stdio.h>
#include "mpi.h"
int main(int argc, char* argv[]) {
int ProcNum, ProcRank, RecvRank;
MPI_Status Status;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &ProcNum);
MPI_Comm_rank(MPI_COMM_WORLD, &ProcRank);
if (ProcRank == 0) {
// Действия, выполняемые только процессом с рангом 0
printf("\n Hello from process %3d", ProcRank);
for (int i = 1; i < ProcNum; i++) {
MPI_Recv(&RecvRank, 1, MPI_INT, MPI_ANY_SOURCE,
MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
printf("\n Hello from process %3d", RecvRank);
}
}
else // Сообщение, отправляемое всеми процессами,
// кроме процесса с рангом 0
MPI_Send(&ProcRank, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}
Visual Studio show errors:
1>------ Build started: Project: OpenMPISample, Configuration: Debug
Win32 ------ 1>Source.obj : error LNK2001: unresolved external symbol
_ompi_mpi_comm_world 1>Source.obj : error LNK2001: unresolved external symbol _ompi_mpi_int 1>C:\Users\Andriy\Documents\Visual Studio
2015\Projects\OpenMPISample\Debug\OpenMPISample.exe : fatal error
LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How to connect OpenMPI library to Visual Studio 2015 correctly? Thanks in advance!

using Aquila in Visual Studio 2012

First i make Aquila by Cmake
and then open the Aquila.sln file that generated by Cmake
and then from build menu and batch build check the
Aquila Debug Win32 Debug|Win32
Aquila Release Win32 Release|Win32
and generate Aquila.lib
and added this library and .h files in my solution for running the example but I have this error:
Error 1 error LNK2019: unresolved external symbol _cdft referenced in
function "public: virtual class std::vector,class std::allocator >
__thiscall Aquila::OouraFft::fft(double const * const)" (?fft#OouraFft#Aquila##UAE?AV?$vector#V?$complex#N#std##V?$allocator#V?$complex#N#std###2##std##QBN#Z) C:...\aquila\Aquila.lib(OouraFft.obj)
Then i change Runtime Library from Multi threaded debuge DLL (/MDd) to
Multi threaded debuge (/MTd)
but have this error: Error 1 error LNK2038: mismatch detected for
'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value
'MTd_StaticDebug' in
aquila.obj C:...\aquila\Aquila.lib(SignalSource.obj)
Aquila example
#include "aquila/aquila.h"
#include "stdafx.h"
int main()
{
// input signal parameters
const std::size_t SIZE = 64;
const Aquila::FrequencyType sampleFreq = 2000, f1 = 125, f2 = 700;
Aquila::SineGenerator sine1(sampleFreq);
sine1.setAmplitude(32).setFrequency(f1).generate(SIZE);
Aquila::SineGenerator sine2(sampleFreq);
sine2.setAmplitude(8).setFrequency(f2).setPhase(0.75).generate(SIZE);
auto sum = sine1 + sine2;
Aquila::TextPlot plot("Input signal");
plot.plot(sum);
// calculate the FFT
auto fft = Aquila::FftFactory::getFft(SIZE);
Aquila::SpectrumType spectrum = fft->fft(sum.toArray());
plot.setTitle("Spectrum");
plot.plotSpectrum(spectrum);
return 0;
}
Is there any one cane help me????
If you use aquila 3.0, after building aquila with cmake, Ooura_fft.lib must be in aquila-build/lib/Debug/Ooura_fft.lib. You have to link it to your project.

Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' on Visual Studio 2010 C ++? [duplicate]

This question already has answers here:
error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
(13 answers)
Closed 9 years ago.
I get the following error Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' when I compile my code using Win32 Console Application.
I tried fixing it my going into Projects -> Properties -> General -> Linker -> Enable Incremental Linking and I changed it from "Yes" to No (/INCREMENTAL:NO) and then I tried to debug my code again but got another error message :
1>------ Build started: Project: Someproject, Configuration: Debug Win32 ------
1>project1.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
1>c:\users\anne\documents\visual studio 2010\Projects\Someproject\Debug\Someproject.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How can I fix it?
#include <Windows.h>
#include <process.h>
#include <stdio.h>
#include <math.h>
volatile int counter = 0;
int isPrime(int n)
{
for(int i = 2; i < (int)(sqrt((float)n) + 1.0) ; i++) {
if (n % i == 0) return 0;
}
return 1;
}
unsigned int __stdcall mythread(void*)
{
char* s;
while (counter < 25) {
int number = counter++;
s = "No";
if(isPrime(number)) s = "Yes";
printf("Thread %d value = %d is prime = %s\n",
GetCurrentThreadId(), number, s);
}
return 0;
}
int main(int argc, char* argv[])
{
HANDLE myhandleA, myhandleB;
myhandleA = (HANDLE)_beginthreadex(0, 0, &mythread, (void*)0, 0, 0);
myhandleB = (HANDLE)_beginthreadex(0, 0, &mythread, (void*)0, 0, 0);
WaitForSingleObject(myhandleA, INFINITE);
WaitForSingleObject(myhandleB, INFINITE);
CloseHandle(myhandleA);
CloseHandle(myhandleB);
getchar();
system("pause");
return 0;
}
The basic problem is that you somehow specified "windows app" in your project settings. You want "console app" instead.
Windows apps use "WinMain()"; console apps use "main()".
Look at this link for details:
error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
See also:
Building Console Applications

Compiling Mathlink Code in Visual Studio 2010 Express LNK2019 Error

I'm attempting to compile a simple C file for use with Mathematica. (Note: I did follow the rest of the instructions, creating the empty addtwotm.c file and adding addtwo.tm)
#include "mathlink.h"
extern int addtwo( int i, int j);
int addtwo( int i, int j)
{
return i+j;
}
#if WINDOWS_MATHLINK
#if __BORLANDC__
#pragma argsused
#endif
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
{
char buff[512];
char FAR * buff_start = buff;
char FAR * argv[32];
char FAR * FAR * argv_end = argv + 32;
hinstPrevious = hinstPrevious; /* suppress warning */
if( !MLInitializeIcon( hinstCurrent, nCmdShow)) return 1;
MLScanString( argv, &argv_end, &lpszCmdLine, &buff_start);
return MLMain( (int)(argv_end - argv), argv);
}
#else
int main(int argc, char* argv[])
{
return MLMain(argc, argv);
}
#endif
However, on build, I get this output:
1>------ Build started: Project: addtwo, Configuration: Debug Win32 ------
1> Performing Custom Build Tools
1> on "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VC\bin\mprep.exe" "" -o "D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\addtwo\..\addtwotm.c"
1>addtwo.obj : error LNK2019: unresolved external symbol _MLMain referenced in function _WinMain#16
1>addtwo.obj : error LNK2019: unresolved external symbol _MLInitializeIcon referenced in function _WinMain#16
1>D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\Debug\addtwo.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've followed all provided instructions from Wolfram's MathLink Developer Guide, and made sure to add "ml32i3m.lib" to Linker>Input>Additional Dependencies. Supposedly the ml32/ml64 lib files contain the information for MlMain. Any help is appreciated :)