Link 1120 ошибка

Reee

21 / 21 / 7

Регистрация: 21.09.2010

Сообщений: 65

1

12.10.2010, 15:02. Показов 46866. Ответов 12

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Поскажите где ошибка?

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
using namespace std;
 
 
int main()
{
    for(;;)
    {
    char* III1="S";
    char* III2="D";
    char* III3="F";
    char* III4="G";
    char* III5="H";
    int a=0;
    cin>>a;
    switch(a)
    {
    case 1 : cout<<III1<<endl;
        break;
    case 2 : cout<<III2<<endl;
        break;
    case 3 : cout<<III3<<endl;
        break;
    case 4 : cout<<III4<<endl;
        break;
    case 5 : cout<<III5<<endl;
        break;
    }
    cout<<"Продолжить?"<<endl;
    char vvod;
    cin>>vvod;
    if(vvod=='y'||vvod=='Y')
        break;
    else
        cout<<"Вы продолжили..."<<endl;
    }
    return 0;
}

1>LINK : error LNK2001: неразрешенный внешний символ «_mainCRTStartup»
1>D:2010 profesional45165Debug45165.exe : fatal error LNK1120: 1 неразрешенных внешних элементов
1>
1>СБОЙ построения.



0



dihlofos

Бродяга

314 / 268 / 56

Регистрация: 27.08.2010

Сообщений: 553

12.10.2010, 15:04

2

Может из-за этого:

C++
1
cout<<"Продолжить?"<<endl;



0



21 / 21 / 7

Регистрация: 21.09.2010

Сообщений: 65

12.10.2010, 15:06

 [ТС]

3

Не… не это.



0



70 / 44 / 9

Регистрация: 10.08.2010

Сообщений: 140

12.10.2010, 15:11

4

В коде грубых ошибок (логика не имеется ввиду=) ) нет, компилируется и даже практически работает. Смотрите в сторону настроек линковщика.



0



asics

Freelance

Эксперт С++

2890 / 1825 / 356

Регистрация: 09.09.2010

Сообщений: 3,841

12.10.2010, 15:43

5

Разве не так надо писать ?

C++
1
char* III1='S';



0



Эксперт С++

5054 / 3115 / 271

Регистрация: 11.11.2009

Сообщений: 7,045

12.10.2010, 15:55

6

Нет, так вы инициализируете указатель символом S, это ошибка. А так указатель будет указывать на строку «S», которая к тому же имеет нуль-терминатор в конце.



0



21 / 21 / 7

Регистрация: 21.09.2010

Сообщений: 65

12.10.2010, 16:41

 [ТС]

7

Цитата
Сообщение от Юрий АЛексеевич
Посмотреть сообщение

В коде грубых ошибок (логика не имеется ввиду=) ) нет, компилируется и даже практически работает. Смотрите в сторону настроек линковщика.

А если я там ничево не трогал?Гдет ниделю назад всё было нормально, а щас вот так.(Тоесть программой ваще не пользовался.)

Добавлено через 30 минут
Что могло сбится в настройках Microsoft Visual Studio 2010?
Так как мой пример норм работает в Microsoft Visual C++ 2008 Express Edition.



0



1562 / 1040 / 94

Регистрация: 17.04.2009

Сообщений: 2,995

12.10.2010, 18:06

8

Какая то lib не подключена, где описывается _mainCRTStartup



0



Freelance

Эксперт С++

2890 / 1825 / 356

Регистрация: 09.09.2010

Сообщений: 3,841

12.10.2010, 18:41

9

Запишы ето /entry:»mainCRTStartup в проектсвойствакомпоновщиккомандная строкадопольнителние опции



1



2 / 2 / 1

Регистрация: 08.09.2010

Сообщений: 10

12.10.2010, 20:48

10

у меня была такая проблема, и дело было вот в чем. Студия (у меня 2010) по умолчанию вместо main юзает _tmain (для конс.прил.) попробуйте создать мастером проэкт, с готовым заголовком, и посмотрите как там называеться мэйн.



0



Freelance

Эксперт С++

2890 / 1825 / 356

Регистрация: 09.09.2010

Сообщений: 3,841

12.10.2010, 20:53

11

Tim0xAA, не только MSVS10 юзает по дефу _tmain,и вопше дело не в етом,в студии можно щитать что main ето синоним слова _tmain.



0



Эксперт JavaЭксперт С++

8380 / 3612 / 419

Регистрация: 03.07.2009

Сообщений: 10,708

13.10.2010, 14:20

12

Clean, а потом Rebuild Solution



0



бжни

2473 / 1684 / 135

Регистрация: 14.05.2009

Сообщений: 7,162

13.10.2010, 16:20

13

в Linker/System/Subsystem должно быть Console (/SUBSYSTEM:CONSOLE) или Not Set



1



Дан код GitHub
При попытке компиляции выдает это

1>------ Build started: Project: SimpleLang, Configuration: Debug Win32 ------
1>  Parser.cpp
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:UsersDanielDocumentsGitHubSimpleLangDebugSimpleLang.exe : fatal error LNK1120: 1 unresolved externals
2>------ Build started: Project: Tests, Configuration: Debug Win32 ------
2>  Parser_GetType.cpp
2>Parser_GetType.obj : error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Parser::GetType(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?GetType@Parser@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z) referenced in function "private: virtual void __thiscall ParserTest_identifer_Test::TestBody(void)" (?TestBody@ParserTest_identifer_Test@@EAEXXZ)
2>C:UsersDanielDocumentsGitHubSimpleLangDebugTests.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 2 failed, 1 up-to-date, 0 skipped ==========

I was writing a C++ program in visual studio 2013 and the
program is very simple one and when I compile there was error
this is third time I see this error.
Here’s the program:

#include <iostream>
using namespace std;

int main()
{
    int x, y, z = 0;
    char c;
    bool quit = true;

    while (quit == true)
    {
        cout << "enter a number : ";
        cin >> x;
        cout << "enter a sign : ";
        cin >> c;
        cout << "enter another number : ";
        cin >> y;

        if (c == '+')
            z = x + y;
        if (c == '-')
            z = x - y;
        if (c == '*')
            z = x * y;
        if (c == '/' && y != 0)
            z = x / y;
        if (c == 'q')
            quit = false;

        cout << "Answer is : " << z << endl;
    }

    return 0;
}

…and here’s the error:

1>------ Build started: Project: Calculator_madeByMe, Configuration: Debug Win32 ------
1>  Source.cpp
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:UsersSorenadocumentsvisual studio 2013ProjectsCalculator_madeByMeDebugCalculator_madeByMe.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========>

Jerry Coffin's user avatar

Jerry Coffin

472k80 gold badges621 silver badges1107 bronze badges

asked May 23, 2014 at 23:13

Sorena's user avatar

2

Your compiling as a Windows application, which does not use the «int main()» signature when calling the entry point.

Switch to a console application in Project -> Properties -> Linker -> System -> SubSystem -> Console. There might be more involved than just this setting, so if it still doesn’t compile, remake your project and make sure to choose Console Application.

answered May 23, 2014 at 23:19

mukunda's user avatar

mukundamukunda

2,89915 silver badges20 bronze badges

Permalink

Cannot retrieve contributors at this time

title description ms.date f1_keywords helpviewer_keywords ms.assetid

Linker tools error LNK1120

Describes the LNK1120 linker error, which reports the number of unresolved external symbol errors in the link.

10/31/2019

LNK1120

LNK1120

56aa7d36-921f-4daf-b44d-cca0d4fb1b51

number unresolved externals

Error LNK1120 reports the number of unresolved external symbol errors in the current link.

Each unresolved external symbol first gets reported by a LNK2001 or LNK2019 error. The LNK1120 message comes last, and shows the unresolved symbol error count.

[!IMPORTANT]
You don’t need to fix this error. This error goes away when you correct all of the LNK2001 and LNK2019 linker errors before it in the build output. Always fix issues starting at the first reported error. Later errors may be caused by earlier ones, and go away when the earlier errors are fixed.

I get the ERROR LNK1120: 1 unresolved externals & ERROR LNK2019: unresolved external symbol ! While Compiling

Some threads — I end up while searching — say is something about class definitions and other that is something with the .cpp /.h files

The errors:

ERROR LNK1120: 1 unresolved externals.  

ERROR LNK2019: unresolved external symbol "public: __thiscall bandera_Triang::~bandera_Triang(void)" (??1bandera_Triang@@QAE@XZ) referenced in function _main.

Here is the code:

#include <iostream>
using namespace std;

class bandera_Triang {
private:
    float aSide, bSide, cSide;

public:
    bandera_Triang(){ //Cost. sin Param...
        aSide = 0;
        bSide = 0;
        cSide = 0;
    }
    bandera_Triang(float A, float B, float C){ //Const. con Param...
        aSide = A;
        bSide = B;
        cSide = C;
    }

    //Sets...
    void set_A(float A){ aSide = A; }
    void set_B(float B){ bSide = B; }
    void set_C(float C){ cSide = C; }

    //Gets...
    float get_A(){ return aSide; }
    float get_B(){ return bSide; }
    float get_C(){ return cSide; }

    ~bandera_Triang(); //destructor...



    bool esTriang(){ //Desigualdad Triangular...
        if (aSide < bSide + cSide && bSide < aSide + cSide && cSide < aSide + bSide) {
            return true;
        }
        else
            return false;
    }

    string triangOno(bool esTriang()){ //Print si es o no triangulo...
        if (esTriang() == true){
            return "Es Triangulo.";
        }
        else { return "NO es Triangulo."; }
    }

    string tipoTriang(){
        if (aSide == bSide && bSide == cSide){
            return "El triangulo es Equilatero.";
        }
        else
        if (aSide == bSide || aSide == cSide || bSide == cSide){
            return "El triangulo es Isosceles. ";
        }
        return "El triangulo es Escaleno.";
    }

    float arTriang(float aSide, float bSide, float cSide){ //Area Triangulo con F.Heron.

        float lado_A, lado_B, lado_C, SemiPerim, areaTriang; //Variables locales para calculo.

        SemiPerim = (lado_A + lado_B + lado_C) / 2; //Calculo de Semiperimetro.

        areaTriang = sqrt(SemiPerim * (SemiPerim - lado_A) * (SemiPerim - lado_B) * (SemiPerim - lado_C));

        return areaTriang;
    }

    string printArea(float arTriang){ cout << "El area del Triangulo es: " << arTriang << "cm2." << endl; } //Imprime Area :)
}; //Fin Clase Triangulo


//Inicia Main

int main(){

    bandera_Triang triangA;

    system("pause");
} 

nicael's user avatar

nicael

18.4k13 gold badges57 silver badges90 bronze badges

asked Apr 5, 2015 at 7:12

10110's user avatar

4

There are two steps to creating the executable, compiling and linking. During the compilation phase, you sometimes only make a promise, like «there is a function int foo(float)» even though that function isn’t part of this compilation unit. The compiler will take your word and only insert a placeholder. Later on, the linker will assemble the different parts of your program and resolve that placeholder. Since it doesn’t find the promised function, it errors out.

The promised function is the destructor, which you declared (~bandera_Triang();) but never actually provided. If you didn’t promise to provide one, the compiler would have created this special function for you, so I’d suggest you just remove the declaration. In order to let the teacher know you considered this, you can write it like this:

// default dtor is fine
// ~bandera_Triang();

or you could implement it with an empty body.

answered Apr 5, 2015 at 7:26

Ulrich Eckhardt's user avatar

Ulrich EckhardtUlrich Eckhardt

16.5k3 gold badges28 silver badges54 bronze badges

2

Понравилась статья? Поделить с друзьями:
  • Lineage 2 ошибка cannot run in this
  • Lineage 2 выдает ошибку при запуске
  • Lineage 2 gameguard ошибка 153
  • Lineage 2 essence ошибка 400 при скачивании
  • Line of sight ошибка