none
LINK : fatal error LNK1561: entry point must be defined

    Question

  • I am trying to make an executable from source code, headers, etc.

    I am using Visual Studio 10.0.

    I get this message.

    Can someone help me?

    Thanks.

    LINK : fatal error LNK1561: entry point must be defined

    Saturday, February 05, 2011 12:11 PM

All replies

  • Raleigh77 wrote:

    I am trying to make an executable from source code, headers, etc.

    LINK : fatal error LNK1561: entry point must be defined

    You haven't defined a function named main or wmain or WinMain or  wWinMain.


    Igor Tandetnik

    Saturday, February 05, 2011 3:23 PM
  • If please possible quote the program or just the part of program which consist your entry point of your program. i.e. the part of program having the Main() fuction is it is a console program, the cmd type. or WinMain() function if a windows program. If there isn't one such function then thats is your problem. Your program must have a entry point fuction in other words the function from which your program starts. There might be a possibilty you might have misstyped the fuction name incorrectly.
    Saturday, February 05, 2011 4:40 PM
  • >There might be a possibilty you might have misstyped
    >the fuction name incorrectly.

    <evil grin> As you did when you typed:

    >...the part of program which consist your entry point
    >of your program. i.e. the part of program having the
    >Main() fuction is it is a console program ...

    It should be: "main() function ..."

    C and C++ are case-sensitive languages. The names
    "main" and "Main" are not the same.

    - Wayne
    Saturday, February 05, 2011 5:54 PM
  • Thanks.

    This came from here.

    http://msdn.microsoft.com/en-us/library/aa363680%28v=vs.85%29.aspx

    Andy

    // report_event
    #ifndef UNICODE
    #define UNICODE
    #endif
    #include <windows.h>
    #include <stdio.h>
    #include "provider.h"

    #pragma comment(lib, "advapi32.lib")

    #define PROVIDER_NAME L"MyEventProvider"

    // Hardcoded insert string for the event messages.
    CONST LPWSTR pBadCommand = L"The command that was not valid";
    CONST LPWSTR pFilename = L"c:\\folder\\file.ext";
    CONST LPWSTR pNumberOfRetries = L"3";
    CONST LPWSTR pSuccessfulRetries = L"0";
    CONST LPWSTR pQuarts = L"8";
    CONST LPWSTR pGallons = L"2";

    void wmain(void)
    {
        HANDLE hEventLog = NULL;
        LPWSTR pInsertStrings[2] = {NULL, NULL};
        DWORD dwEventDataSize = 0;

        // The source name (provider) must exist as a subkey of Application.
        hEventLog = RegisterEventSource(NULL, PROVIDER_NAME);
        if (NULL == hEventLog)
        {
            wprintf(L"RegisterEventSource failed with 0x%x.\n", GetLastError());
            goto cleanup;
        }

        // This event includes user-defined data as part of the event. The event message
        // does not use insert strings.
        dwEventDataSize = ((DWORD)wcslen(pBadCommand) + 1) * sizeof(WCHAR);
        if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, UI_CATEGORY, MSG_INVALID_COMMAND, NULL, 0, dwEventDataSize, NULL, pBadCommand))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(), MSG_INVALID_COMMAND);
            goto cleanup;
        }

        // This event uses insert strings.
        pInsertStrings[0] = pFilename;
        if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, DATABASE_CATEGORY, MSG_BAD_FILE_CONTENTS, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(), MSG_BAD_FILE_CONTENTS);
            goto cleanup;
        }

        // This event uses insert strings.
        pInsertStrings[0] = pNumberOfRetries;
        pInsertStrings[1] = pSuccessfulRetries;
        if (!ReportEvent(hEventLog, EVENTLOG_WARNING_TYPE, NETWORK_CATEGORY, MSG_RETRIES, NULL, 2, 0, (LPCWSTR*)pInsertStrings, NULL))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(), MSG_RETRIES);
            goto cleanup;
        }

        // This event uses insert strings.
        pInsertStrings[0] = pQuarts;
        pInsertStrings[1] = pGallons;
        if (!ReportEvent(hEventLog, EVENTLOG_INFORMATION_TYPE, UI_CATEGORY, MSG_COMPUTE_CONVERSION, NULL, 2, 0, (LPCWSTR*)pInsertStrings, NULL))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(), MSG_COMPUTE_CONVERSION);
            goto cleanup;
        }

        wprintf(L"All events successfully reported.\n");

    cleanup:

        if (hEventLog)
            DeregisterEventSource(hEventLog);
    }

    Saturday, February 05, 2011 9:49 PM
  • I am using Visual Studio 10.0.

    I get this message.

    LINK : fatal error LNK1561: entry point must be defined

    The code came from here.

    http://msdn.microsoft.com/en-us/library/aa363680%28v=vs.85%29.aspx

    Could someone help me with this problem?

    Thanks.

    // report_event
    #ifndef UNICODE
    #define UNICODE
    #endif
    #include <windows.h>
    #include <stdio.h>
    #include "provider.h"

    #pragma comment(lib, "advapi32.lib")

    #define PROVIDER_NAME L"MyEventProvider"

    // Hardcoded insert string for the event messages.
    CONST LPWSTR pBadCommand = L"The command that was not valid";
    CONST LPWSTR pFilename = L"c:\\folder\\file.ext";
    CONST LPWSTR pNumberOfRetries = L"3";
    CONST LPWSTR pSuccessfulRetries = L"0";
    CONST LPWSTR pQuarts = L"8";
    CONST LPWSTR pGallons = L"2";

    void wmain(void)
    {
        HANDLE hEventLog = NULL;
        LPWSTR pInsertStrings[2] = {NULL, NULL};
        DWORD dwEventDataSize = 0;

        // The source name (provider) must exist as a subkey of Application.
        hEventLog = RegisterEventSource(NULL, PROVIDER_NAME);
        if (NULL == hEventLog)
        {
            wprintf(L"RegisterEventSource failed with 0x%x.\n", GetLastError());
            goto cleanup;
        }

        // This event includes user-defined data as part of the event. The event message
        // does not use insert strings.
        dwEventDataSize = ((DWORD)wcslen(pBadCommand) + 1) * sizeof(WCHAR);
        if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, UI_CATEGORY, MSG_INVALID_COMMAND, NULL, 0,

    dwEventDataSize, NULL, pBadCommand))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(),

    MSG_INVALID_COMMAND);
            goto cleanup;
        }

        // This event uses insert strings.
        pInsertStrings[0] = pFilename;
        if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, DATABASE_CATEGORY, MSG_BAD_FILE_CONTENTS,

    NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(),

    MSG_BAD_FILE_CONTENTS);
            goto cleanup;
        }

        // This event uses insert strings.
        pInsertStrings[0] = pNumberOfRetries;
        pInsertStrings[1] = pSuccessfulRetries;
        if (!ReportEvent(hEventLog, EVENTLOG_WARNING_TYPE, NETWORK_CATEGORY, MSG_RETRIES, NULL, 2, 0,

    (LPCWSTR*)pInsertStrings, NULL))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(), MSG_RETRIES);
            goto cleanup;
        }

        // This event uses insert strings.
        pInsertStrings[0] = pQuarts;
        pInsertStrings[1] = pGallons;
        if (!ReportEvent(hEventLog, EVENTLOG_INFORMATION_TYPE, UI_CATEGORY, MSG_COMPUTE_CONVERSION,

    NULL, 2, 0, (LPCWSTR*)pInsertStrings, NULL))
        {
            wprintf(L"ReportEvent failed with 0x%x for event 0x%x.\n", GetLastError(),

    MSG_COMPUTE_CONVERSION);
            goto cleanup;
        }

        wprintf(L"All events successfully reported.\n");

    cleanup:

        if (hEventLog)
            DeregisterEventSource(hEventLog);
    }

    • Merged by lucy-liuModerator Wednesday, February 09, 2011 3:11 AM Merge them to keep in the same topic
    Sunday, February 06, 2011 1:12 AM
  • Configuration Properties, Linker, System, SubSystem => set to Console (/SUBSYSTEM:CONSOLE)

     

    Sunday, February 06, 2011 4:21 AM
  • Configuration Properties, Linker, System, SubSystem => set to Console (/SUBSYSTEM:CONSOLE)

    Duplicate post.

     

    Sunday, February 06, 2011 4:22 AM
  • Hi Raleigh77,

    As Brian said, it is a duplicate post. I will merge it with the post http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/ac2a2fb7-f72b-4b35-978f-edba8fabc920/ .

    Thank you for understanding,

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 09, 2011 3:10 AM
  • Thanks.

    I uninstalled V.S. because of the difficulty of using it.

    I used the Pro version, and it took about 6 hrs. to download and install.

    I am rethinking if it would be worth the time and effort for what I would probably use

    for only one C ++ source.

    I currently use masm and it's linker to produce 32 bit programs using assembly source code.

    Andy

     

     

     

     

    Wednesday, February 09, 2011 12:59 PM
  • Thanks.

    Andy

     

    Wednesday, February 09, 2011 1:00 PM
  • Hi Raleigh77,

    Have you solved your issue?

    If you have solved, please mark the useful reply as answer.

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 14, 2011 11:16 AM
  • No help has worked. Does someone have some working code in C that uses ReportEvent? Thanks.
    Monday, February 14, 2011 7:47 PM
  • >Does someone have some working code in C that uses ReportEvent?

    The code from the URL you posted compiles without errors or
    warnings for me using VC++ 2008 Express.

    You need to supply more information about what you are
    doing and how you are doing it, if you want detailed
    help. You have made no mention of *exactly* how you
    have tried to build this example. From the IDE?
    From the command line? If IDE, using which Project
    Template? If from the command line, what was the
    actual and complete command used?

    - Wayne
    Monday, February 14, 2011 10:58 PM
  • I have the required dll file and header file for the project.

    I used the 2003 PSDK to make those.

    I believe in order to test if it works would require changing the path to that dll file.

    I am willing to reinstall VC Express if I know that the program will actually work.

    I could upload those files in order to assist in any way.

    Could you do that for me?

    Maybe a screen shot of the results?

    Thanks,

    Andy

     

     

     

     

     

    Tuesday, February 15, 2011 12:35 AM
  • I am at this point in my project.

    Where is the Win32 App Wizard?

    1. In the Win32 Application Wizard , click Application Settings to reveal options for Application type. Under Additional Options , select Empty Project and then click Finish .

    2. Further on down is this.

    3. Can I go straight to making the executable?

    Can I stop the autoformatting for my replies?

    Thanks.

    1. To build and examine the program

      1. On the Build menu, click Build Solution .

        The Output window displays information about the compilation progress, for example, the location of the build log and a message that states the build status.

      2. On the Debug menu, click Start without Debugging .

        If you used the sample program, a command window is displayed and shows whether certain integers are found in the set.

    Tuesday, February 15, 2011 2:21 AM
  • Hello Raleigh77,

    If you compiling from command line, just add /entry:wmain

    Regards,

    Andrew

    Tuesday, February 15, 2011 2:55 AM
  • Thanks Andrew.

     

    I have used Visual C++ only about 10 times.

    I will look at the help section for command line and see what is involved.

     

    Andy

    Tuesday, February 15, 2011 7:41 AM
  • Clicked on Building on the Command Line and got:

     

    Information Not Found
    See Also   Send Feedback
    Tuesday, February 15, 2011 7:46 AM
  • Walkthrough:  Compiling a Native C++ Program on the Command Line (C++)

    http://msdn.microsoft.com/en-us/library/ms235639.aspx

    - Wayne

    Tuesday, February 15, 2011 7:59 AM
  • Thanks, seeing some good progress.

    Andy

    report_event.cpp
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\provider.h(25) : error C2470: 'Provider' : looks like a function definition, but there is no parameter list; skipping apparent body
    report_event.cpp(38) : error C2065: 'UI_CATEGORY' : undeclared identifier
    report_event.cpp(38) : error C2065: 'MSG_INVALID_COMMAND' : undeclared identifier
    report_event.cpp(40) : error C2065: 'MSG_INVALID_COMMAND' : undeclared identifier
    report_event.cpp(46) : error C2065: 'DATABASE_CATEGORY' : undeclared identifier
    report_event.cpp(46) : error C2065: 'MSG_BAD_FILE_CONTENTS' : undeclared identifier
    report_event.cpp(48) : error C2065: 'MSG_BAD_FILE_CONTENTS' : undeclared identifier
    report_event.cpp(55) : error C2065: 'NETWORK_CATEGORY' : undeclared identifier
    report_event.cpp(55) : error C2065: 'MSG_RETRIES' : undeclared identifier
    report_event.cpp(57) : error C2065: 'MSG_RETRIES' : undeclared identifier
    report_event.cpp(64) : error C2065: 'UI_CATEGORY' : undeclared identifier
    report_event.cpp(64) : error C2065: 'MSG_COMPUTE_CONVERSION' : undeclared identifier
    report_event.cpp(66) : error C2065: 'MSG_COMPUTE_CONVERSION' : undeclared identifier

    Tuesday, February 15, 2011 8:21 AM
  • C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\provider.h(25) : error C2470: 'Provider' : looks like a function definition, but there is no parameter list; skipping apparent body
    Are we supposed to guess what line 25 of provider.h contains?

    - Wayne

    Tuesday, February 15, 2011 8:32 AM
  •  // MyEventProvider.mc
     // This is the header section.
     // The following are the categories of events.
    //
    //  Values are 32 bit values layed out as follows:
    //
    //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
    //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
    //  +---+-+-+-----------------------+-------------------------------+
    //  |Sev|C|R|     Facility          |               Code            |
    //  +---+-+-+-----------------------+-------------------------------+
    //
    //  where
    //
    //      Sev - is the severity code
    //
    //          00 - Success
    //          01 - Informational
    //          10 - Warning
    //          11 - Error
    //
    //      C - is the Customer code flag
    //
    //      R - is a reserved bit
    //
    //      Facility - is the facility code
    //
    //      Code - is the facility's status code
    //
    //
    // Define the facility codes
    //
    #define FACILITY_SYSTEM                  0x0
    #define FACILITY_STUBS                   0x3
    #define FACILITY_RUNTIME                 0x2
    #define FACILITY_IO_ERROR_CODE           0x4


    //
    // Define the severity codes
    //
    #define STATUS_SEVERITY_WARNING          0x2
    #define STATUS_SEVERITY_SUCCESS          0x0
    #define STATUS_SEVERITY_INFORMATIONAL    0x1
    #define STATUS_SEVERITY_ERROR            0x3


    //
    // MessageId: NETWORK_CATEGORY
    //
    // MessageText:
    //
    //  Network Events
    //
    #define NETWORK_CATEGORY                 ((WORD)0x00000001L)

    //
    // MessageId: DATABASE_CATEGORY
    //
    // MessageText:
    //
    //  Database Events
    //
    #define DATABASE_CATEGORY                ((WORD)0x00000002L)

    //
    // MessageId: UI_CATEGORY
    //
    // MessageText:
    //
    //  UI Events
    //
    #define UI_CATEGORY                      ((WORD)0x00000003L)

     // The following are the message definitions.
    //
    // MessageId: MSG_INVALID_COMMAND
    //
    // MessageText:
    //
    //  The command is not valid.
    //
    #define MSG_INVALID_COMMAND              ((DWORD)0xC0020100L)

    //
    // MessageId: MSG_BAD_FILE_CONTENTS
    //
    // MessageText:
    //
    //  File %1 contains content that is not valid.
    //
    #define MSG_BAD_FILE_CONTENTS            ((DWORD)0xC0000101L)

    //
    // MessageId: MSG_RETRIES
    //
    // MessageText:
    //
    //  There have been %1 retries with %2 success! Disconnect from
    //  the server and try again later.
    //
    #define MSG_RETRIES                      ((DWORD)0x80000102L)

    //
    // MessageId: MSG_COMPUTE_CONVERSION
    //
    // MessageText:
    //
    //  %1 %%4096 = %2 %%4097.
    //
    #define MSG_COMPUTE_CONVERSION           ((DWORD)0x40000103L)

     // The following are the parameter strings */
    //
    // MessageId: QUARTS_UNITS
    //
    // MessageText:
    //
    //  quarts%0
    //
    #define QUARTS_UNITS                     ((DWORD)0x00001000L)

    //
    // MessageId: GALLONS_UNITS
    //
    // MessageText:
    //
    //  gallons%0
    //
    #define GALLONS_UNITS                    ((DWORD)0x00001001L)

    Tuesday, February 15, 2011 8:35 AM
  • <sigh> Are we supposed to guess which line generated the error?

    - Wayne
    Tuesday, February 15, 2011 8:42 AM
  • If you can't help me without criticizing me, then I can do without your "Help."

    Andy

     

    Tuesday, February 15, 2011 11:26 AM
  • Raleigh77 wrote:
    >
    >Thanks, seeing some good progress.
    >
    >Andy
    >
    >report_event.cpp
    >C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\provider.h(25) : error C2470: 'Provider' : looks like a function definition, but there is no parameter list; skipping apparent body
    >report_event.cpp(38) : error C2065: 'UI_CATEGORY' : undeclared identifier
     
    Are you including <windows.h> as your first include? The word before
    "Provider" in provider.h is POLARITY, which is defined in <polarity.h>,
    which should have been included, if you did things in the proper order.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP
    Saturday, February 19, 2011 10:26 PM
  • Thanks Tim.

    There is no reference to Polarity in any of my sources.

    I am using everything at the website that was provided.

    I will have to check but I believe that windows.h is in the source code.

    I assume that VB C++ knows what to do and that it was included in the package

    that I downloaded.

    Andy

     

     

    Saturday, February 19, 2011 10:41 PM
  • I found this. Is this the right one?

    Andy

    /*++

    Copyright (C) 1999 Microsoft Corporation

    Module Name:

    POLARITY.H

    Abstract:

    properly map __declspec( dllexport ) or import

    History:

    --*/


    #if _MSC_VER > 1000
    #pragma once
    #endif

    // If we are building the DLL then define the
    // class as exported otherwise as imported
    // ============================================
    #ifndef POLARITY_HEADERFILE_IS_INCLUDED
    #define POLARITY_HEADERFILE_IS_INCLUDED
    //#pragma message ( "Including Polarity.h..." )

    #ifdef USE_POLARITY
    #ifdef BUILDING_DLL
    // #pragma message ( "Building static library or DLL..." )
    #define POLARITY __declspec ( dllexport )
    #else
    // #pragma message ( "Building Provider..." )
    #define POLARITY __declspec ( dllimport )
    #endif
    #else
    #define POLARITY
    // #pragma message ( "NO Polarity..." )
    #endif
    #endif
    Sunday, February 20, 2011 2:26 PM
  • chocolatemint77581 wrote:
    >
    >There is no reference to Polarity in any of my sources.
     
    Yes, I know that. There are thousands and thousands of standard API
    include files, and those files depend greatly on one another, and on a
    particular ordering. Somehow, you have caused a standard file to be
    included without one of the files it depends on.
     
    That can happen if you #include a specific file by name without including
    <windows.h> first.
     
    >I am using everything at the website that was provided.
    >
    >I will have to check but I believe that windows.h is in the source code.
    >
    >I assume that VB C++ knows what to do and that it was included in the package
    >that I downloaded.
     
    There are rules to be followed to use these APIs. It's a little dangerous
    to start compiling code without understanding what it does.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP
    Monday, February 21, 2011 5:25 AM
  • http://msdn.microsoft.com/en-us/library/aa363677%28v=vs.85%29.aspx

    The source came from above, and as you can see, it is/was from Microsoft.

    The following example shows how to use the NotifyChangeEventLog function to receive notification when an event is logged.

    For the future, I will consider the possibility that any code, may be incomplete.

    But I did learn a lot from the process. :-)

    Take care,

                     Andy

     

     

    Monday, February 21, 2011 5:47 AM
  • chocolatemint77581 wrote:
    >
    >
    >The source came from above, and as you can see, it is/was from Microsoft.
    >
    >The following example shows how to use the NotifyChangeEventLog function to receive notification when an event is logged.
    >
    >For the future, I will consider the possibility that any code, may be incomplete.
     
    I don't see how you get that. I just cut-and-pasted that text into a file
    called x.cpp, then did:
    cl x.cpp
     
    and it compiled and linked without any further ado.
     
    Still, if you have achieved success, that's what matters.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP
    Wednesday, February 23, 2011 6:32 AM
  • #define PROVIDER_NAME L"MyEventProvider"
    #define RESOURCE_DLL L"<path>\\Provider.dll"

    But did your .exe run correctly ?

    If it did, you will have an event at the end of a specified event log.

    ( ReportEvent function writes an entry at the end of the specified event log.)

    I have some other questions for you.

    For the program to work, it needs a path to the dll.

    Did you change <path> to the actual path?

    Did you make provider.dll ?

    And no, I did not achieve sucess.

    Take care,

                    Andy

     

     

     

    Wednesday, February 23, 2011 11:31 AM
  • Hello people,

    I have this problem in VS2010 10.0.30319.1 when i use template. if i put:

    template <typename T>

    int main(){

    return 0;

    }

    i will get this LNK1561 error...


    • Edited by Le10sn Saturday, October 13, 2012 9:52 PM
    Saturday, October 13, 2012 9:47 PM
  • Le10sn wrote:

    I have this problem in VS2010 10.0.30319.1 when i use template. if i  put:

    template <typename T>

    int main(){

    return 0;

    }

    i will get this LNK1561 error...

    main() function cannot be a template. Think about it: main() is called  by the operating system - how is the OS supposed to know which type to  use for T?


    Igor Tandetnik

    • Proposed as answer by madhudskumar Friday, July 18, 2014 4:38 AM
    • Unproposed as answer by madhudskumar Friday, July 18, 2014 4:38 AM
    Saturday, October 13, 2012 11:53 PM