argon bulletin board

Експертно търсене  

Новини:

Регистрирането на нови потребители е временно деактивирано.

Автор Тема: C++ проблем  (Прочетена 1393 пъти)

dRiNKiN_pARk

  • Неактивен Неактивен
  • Публикации: 46
  • [dRiNKiN_pARk]™
    • текстове на български
C++ проблем
« -: 02.10.2005, 19:42:13 »

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/proba.exe : fatal error LNK1120: 1 unresolved externals

на всяка програма ми дава тази грешка.
Явно е, че не е от кода, но как да оправя Visual C++?

П.С.
надявам се, че мога да поместя тази тема в този форум. ако не, моля администраторите и модераторите да ме извинят. :)
Активен

SodomGomor

  • Неактивен Неактивен
  • Публикации: 126
Re: C++ проблем
« Отговор #1 -: 03.10.2005, 09:51:42 »

Така както пишеш ми се струва, че се опитваш да компилираш VC++ код като console application. Надявам се че не е така.
Виж това:

Error LNK2001: unresolved external symbol _main

An unresolved external occurs when some code has a call to a function in another module and the linker can't find that function in any of the modules or libraries that you are currently linking to.
In this specific case, it means one of two things. Either you are trying to write a Win32 GUI application (or non-console application) and accidently compiled it as a Console application... or you really are trying to compile a console application and didn't write or properly compile in a main() function.

Generally the first is the most common, if you specify Win32 Console as the project type in VC++ when you create your project you will get this error. You will also likely get it if you try to compile from the command line using BC++ but you neglect to specify the correct parameters to tell it to make a Win32 GUI application instead of a console app which is the default.

Fixing
If you're using VC++ re-create your project and select the Win32 Application project type (NOT "Console").
If you're using BC++ command line compiler, use -tW to specify a windows application.

Активен
Значи кучета и котки може, а прасета не може!!?

dRiNKiN_pARk

  • Неактивен Неактивен
  • Публикации: 46
  • [dRiNKiN_pARk]™
    • текстове на български
Re: C++ проблем
« Отговор #2 -: 03.10.2005, 12:41:11 »

Fixing:
If you're using VC++ re-create your project and select the Win32 Application project type (NOT "Console").

Visual C++ > File > New > Project > Win32 Application
File > New > File > C++ Source File

Copy - Paste на код от упражненията по C++:

#include <iostream.h>
#include <math.h>

void main ()

{
 double a, sum = 0;
 for ( int i = 0; i < 5; i++ )

 {
  cout << "vyvedete "<< i + 1<< "chislo :";
  cin  >> a;

  sum += a;
 }
 
 cout << "Sumata e: " << sum << endl;
}

Execute Program >

--------------------Configuration: test2 - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/test2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

test2.exe - 2 error(s), 0 warning(s)
Активен

SodomGomor

  • Неактивен Неактивен
  • Публикации: 126
Re: C++ проблем
« Отговор #3 -: 03.10.2005, 13:06:44 »

ама щом като пишеш такава програма трябва да избереш console application. това не е VC++. Може би се бъркаш защото програмата се казва Visual Studio 6.0, но тази програма, която ти си paste-нал тука е console application.

Win32  Application изглежда така:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
}

например. Това е един прост месидж бокс. Този код се компилира като Win32  Application, а твоя като Win32 console application.
Значи

File > New > Project > Win32 Console application
File > New > File > C++ Source File.....
Бля..бля..бля...
Активен
Значи кучета и котки може, а прасета не може!!?

dRiNKiN_pARk

  • Неактивен Неактивен
  • Публикации: 46
  • [dRiNKiN_pARk]™
    • текстове на български
Re: C++ проблем
« Отговор #4 -: 03.10.2005, 13:11:56 »

:))
много благодаря... пак съм спал в упражненията :)
Активен