Re: LNK2005...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ulrich already told you what the problem is, why are you ignoring that?
What you have is a very basic C programming mistake.

I will try to restate, the problem is that you are declaring variables in
the header and I assume those same variables are being declared in a c file
(but maybe not.) Anyway, every file that includes your header is also
declares the same global variables, so you then have multiple declarations.

The proper way to handle this is to declare the variables in the c file and
define them as extern in the header file.

C file:

int myvariable;

H file:

extern int myvarible;

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member


"Ramesh" <Ramesh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3E183F55-28F9-45A4-9406-E8F87516D27A@xxxxxxxxxxxxxxxx
> ,ctually i did,t ge u So acn u please help me
> i am pasting here the contents of the header files
>
> Dialog header:
>
> // testAudioDlg.h : header file
> //
>
> #if
> !defined(AFX_TESTAUDIODLG_H__1420E4DA_1C5D_4D40_9E42_DA362320342D__INCLUDED_)
> #define
> AFX_TESTAUDIODLG_H__1420E4DA_1C5D_4D40_9E42_DA362320342D__INCLUDED_
>
> #if _MSC_VER >= 1000
> #pragma once
> #endif // _MSC_VER >= 1000
>
> /////////////////////////////////////////////////////////////////////////////
> // CTestAudioDlg dialog
>
> class CTestAudioDlg : public CDialog
> {
> // Construction
> public:
> CTestAudioDlg(CWnd* pParent = NULL); // standard constructor
>
> // Dialog Data
> //{{AFX_DATA(CTestAudioDlg)
> enum { IDD = IDD_TESTAUDIO_DIALOG };
> // NOTE: the ClassWizard will add data members here
> //}}AFX_DATA
>
> // ClassWizard generated virtual function overrides
> //{{AFX_VIRTUAL(CTestAudioDlg)
> protected:
> virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
> //}}AFX_VIRTUAL
>
> // Implementation
> protected:
> HICON m_hIcon;
>
> // Generated message map functions
> //{{AFX_MSG(CTestAudioDlg)
> virtual BOOL OnInitDialog();
> afx_msg void OnRecord();
> afx_msg void OnRecordEnd();
> afx_msg void OnPlay();
> //}}AFX_MSG
> DECLARE_MESSAGE_MAP()
> };
>
> //{{AFX_INSERT_LOCATION}}
> // Microsoft eMbedded Visual C++ will insert additional declarations
> immediately before the previous line.
>
> #endif //
> !defined(AFX_TESTAUDIODLG_H__1420E4DA_1C5D_4D40_9E42_DA362320342D__INCLUDED_)
>
>
> testAudio header
>
> // testAudio.h : main header file for the TESTAUDIO application
> //
>
> #if
> !defined(AFX_TESTAUDIO_H__1D6D1E1D_4047_4408_9952_4C74B2359EE3__INCLUDED_)
> #define AFX_TESTAUDIO_H__1D6D1E1D_4047_4408_9952_4C74B2359EE3__INCLUDED_
>
> #if _MSC_VER >= 1000
> #pragma once
> #endif // _MSC_VER >= 1000
>
> #ifndef __AFXWIN_H__
> #error include 'stdafx.h' before including this file for PCH
> #endif
>
> #include "resource.h" // main symbols
> #include "config.h"
>
> /////////////////////////////////////////////////////////////////////////////
> // CTestAudioApp:
> // See testAudio.cpp for the implementation of this class
> //
>
> class CTestAudioApp : public CWinApp
> {
> public:
> CTestAudioApp();
>
> // Overrides
> // ClassWizard generated virtual function overrides
> //{{AFX_VIRTUAL(CTestAudioApp)
> public:
> virtual BOOL InitInstance();
> //}}AFX_VIRTUAL
>
> // Implementation
>
> //{{AFX_MSG(CTestAudioApp)
> // NOTE - the ClassWizard will add and remove member functions here.
> // DO NOT EDIT what you see in these blocks of generated code !
> //}}AFX_MSG
> DECLARE_MESSAGE_MAP()
> };
>
>
> /////////////////////////////////////////////////////////////////////////////
>
> //{{AFX_INSERT_LOCATION}}
> // Microsoft eMbedded Visual C++ will insert additional declarations
> immediately before the previous line.
>
> #endif //
> !defined(AFX_TESTAUDIO_H__1D6D1E1D_4047_4408_9952_4C74B2359EE3__INCLUDED_)
>
>
>
>
> the header file which i have added
>
>
> #ifndef JT_FINAL_SOUND
> #define JT_FINAL_SOUND
>
>
> #include "windows.h"
> #include "mmsystem.h"
>
> #define INP_BUFFER_SIZE 16384;
>
> HWAVEIN hWaveIn;
> HWAVEOUT hWaveOut;
> WAVEFORMATEX waveform;
> PWAVEHDR pWaveHdr1,pWaveHdr2;//hWaveHdr;
> static LPSTR lpBuffer1,lpNewBuffer,lpSaveBuffer;
> DWORD dwDataLength,dwRepetitions = 1;
> static bool brecording=false;
>
> LPSTR block; /* pointer to the block */
> DWORD blockSize; /* holds the size of the block */
>
>
> void CALLBACK waveInProc(
> HWAVEIN hwi,
> UINT uMsg,
> DWORD dwInstance,
> DWORD dwParam1,
> DWORD dwParam2
> );
>
>
> int DoRecord();
> int DoRecord_end();
> int DoPlay();
>
>
> LPSTR loadAudioBlock(const char* filename, DWORD* blockSize);
> void writeAudioBlock(HWAVEOUT hWaveOut, LPSTR block, DWORD size);
>
> #endif /* JT_FINAL_SOUND */
>
>
>
>
>
> In Dialog CPP I included
> #include "stdafx.h"
> #include "testAudio.h"
> #include "testAudioDlg.h"
>
>
> In testAudio cpp
>
> #include "stdafx.h"
> #include "testAudio.h"
> #include "testAudioDlg.h"
>
>
> So is there any conflict, sorry for disturbing you...
>
>
>


.



Relevant Pages

  • [PATCH 3/3] eCryptfs: Encrypted passthrough
    ... whether the metadata is actually in the header or in the extended ... -static void ... size_t size, int flags); ...
    (Linux-Kernel)
  • Writing a service...
    ... the time zone and forces a resync with a time server on initialisation. ... void ServiceMain; ... int InitService; ... int UpdateSCMStatus (DWORD dwCurrentState, DWORD dwWin32ExitCode, ...
    (comp.lang.c)
  • Re: Using multiple files in (Borland) C
    ... project AND used an H-file, ... extern int foo_var; ... void foo_func{ ... definition for each translation unit that includes the header. ...
    (comp.lang.c)
  • [PATCH 1/4] x86 PM: Move 64-bit hibernation files to arch/x86/power
    ... Update the Makefiles in arch/x86, ... -static void fix_processor_context ... -extern int restore_image; ... * kernel's text (this value is passed in the image header). ...
    (Linux-Kernel)
  • Re: Sockets causing deadlock
    ... void CALLBACK ReceiveCallback(IN DWORD dwError, IN DWORD cbTransferred, ... // If we don't have a socket, ... int nError; ...
    (microsoft.public.win32.programmer.networks)