Thursday, May 31, 2018

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

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 
#include
#include
#include

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;
}

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...