• Advertisement
Sign in to follow this  

missing main?

This topic is 4045 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am intializing directsound and I am having errors such as: error LNK2001: unresolved external symbol _main I do not know where this error came from cause I already have made a Winmain. I am making the project as a Win32 application. What am I doing wrong? Here is the source:
#include <dsound.h>
#include <dxerr9.h>
#include "DSUtil.h"
#include "DXUtil.h"
#include "resource.h"

//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
HRESULT DirectSoundCaptureCreate8( LPGUID lpGuid, LPDIRECTSOUND *pDSCapture, IUnknown FAR* pUnkOuter );
INT APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, INT nCmdShow );
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
VOID OnInitDialog( HWND hDlg );

//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
LPDIRECTSOUNDCAPTURE       g_pDSCapture         = NULL;


//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Entry point for the application.  Since we use a simple dialog for 
//       user interaction we don't need to pump messages.
//-----------------------------------------------------------------------------
INT APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, 
                      INT nCmdShow )
{	
	HRESULT hr;
    // Display the main dialog box.
    if( FAILED(DialogBox( hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc )))

    return DXTRACE_ERR_MSGBOX( TEXT("DirectSoundCaptureCreate"), hr );
}

//-----------------------------------------------------------------------------
// Name: InitDirectSound()
// Desc: Initilizes DirectSound
//-----------------------------------------------------------------------------
HRESULT DirectSoundCaptureCreate8( LPGUID lpGuid, LPDIRECTSOUND *pDSCapture, IUnknown FAR* pUnkOuter )
{
    HRESULT hr;

     //Initialize COM
    if( FAILED( hr = CoInitialize(NULL) ) )
        return DXTRACE_ERR_MSGBOX( TEXT("CoInitialize"), hr );


    // Create IDirectSoundCapture using the preferred capture device
    if( FAILED( hr = DirectSoundCaptureCreate8( NULL, &g_pDSCapture, NULL ) ) )
        return DXTRACE_ERR_MSGBOX( TEXT("DirectSoundCaptureCreate"), hr );

    return S_OK;
}

//-----------------------------------------------------------------------------
// Name: MainDlgProc()
// Desc: Handles dialog messages
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
    HRESULT hr;

    switch( msg ) 
    {
        case WM_INITDIALOG:
            OnInitDialog( hDlg );
            break;

        case WM_COMMAND:
            switch( LOWORD(wParam) )
            {
               				case IDCANCEL:
                    EndDialog( hDlg, IDCANCEL );
                    break;

				case IDC_PLAY:
                    // The 'play'/'pause' button was pressed
                    if( FAILED( hr = DirectSoundCaptureCreate8( NULL, &g_pDSCapture, NULL ) ))
                    {
                        DXTRACE_ERR_MSGBOX( TEXT("OnPlaySound"), hr );
                        MessageBox( hDlg, "Error playing DirectSound buffer. "
                                    "Sample will now exit.", "DirectSound Sample", 
                                    MB_OK | MB_ICONERROR );
                        EndDialog( hDlg, IDABORT );
                    }
                    break;
				

				default:
                    return FALSE; // Didn't handle message
			}
			break;

		default:
			return FALSE; // Didn't handle message
	}
	return TRUE; // Handled message
}

//-----------------------------------------------------------------------------
// Name: OnInitDialog()
// Desc: Initializes the dialogs (sets up UI controls, etc.)
//-----------------------------------------------------------------------------
VOID OnInitDialog( HWND hDlg )
{
    //HRESULT hr;


}

Share this post


Link to post
Share on other sites
Advertisement
I had this problem before. Your compiler is by default compiling as a console application. Click file->new->windows32project then create a new c++ file inside of it and then it should compile ok.
-Goten

Share this post


Link to post
Share on other sites
Quote:
Original post by GotenRulezU
I had this problem before. Your compiler is by default compiling as a console application. Click file->new->windows32project then create a new c++ file inside of it and then it should compile ok.
-Goten


You don't need to create a new project. You can go to: Project->Properties->Configuration Properties->Linker->System->Subsystem = Windows.

OP: I agree with LessBread, try searching the forums/google first.


jfl.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement