Erreur de linkage

Signaler
Messages postés
17
Date d'inscription
jeudi 3 juillet 2008
Statut
Membre
Dernière intervention
27 septembre 2008
-
Messages postés
1107
Date d'inscription
mercredi 15 juin 2011
Statut
Membre
Dernière intervention
10 juillet 2018
-
bonjour,
j'ai un projet prgramme avec visual studio C++ 6.0
lors de compilation tout est bien mais à l'exécution j'obtient des erreurs de linkage.
je veux savoir c'est dû à quoi ses erreures et de m'aider à résoudre ces problèmes.
voila les erreurs que j'obtient:
-------------------Configuration: Monnayeur - Win32 Debug--------------------
Linking...
Monnayeur.obj : error LNK2005: "public: __thiscall CAboutDlg::CAboutDlg(void)" (??0CAboutDlg@@QAE@XZ) already defined in ccDLL_TestDlg.obj
Monnayeur.obj : error LNK2005: "protected: virtual void __thiscall CAboutDlg::DoDataExchange(class CDataExchange *)" (?DoDataExchange@CAboutDlg@@MAEXPAVCDataExchange@@@Z) already defined in ccDLL_TestDlg.obj
Monnayeur.obj : error LNK2005: "protected: virtual struct AFX_MSGMAP const * __thiscall CAboutDlg::GetMessageMap(void)const " (?GetMessageMap@CAboutDlg@@MBEPBUAFX_MSGMAP@@XZ) already defined in ccDLL_TestDlg.obj
Monnayeur.obj : error LNK2005: "protected: static struct AFX_MSGMAP const CAboutDlg::messageMap" (?messageMap@CAboutDlg@@1UAFX_MSGMAP@@B) already defined in ccDLL_TestDlg.obj
Monnayeur.obj : error LNK2005: "private: static struct AFX_MSGMAP_ENTRY const * const CAboutDlg::_messageEntries" (?_messageEntries@CAboutDlg@@0QBUAFX_MSGMAP_ENTRY@@B) already defined in ccDLL_TestDlg.obj
ccDLL_TestDlg.obj : error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall ccDLL_TestDlg::GetRuntimeClass(void)const " (?GetRuntimeClass@ccDLL_TestDlg@@UBEPAUCRuntimeClass@@XZ)
Debug/Monnayeur.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Monnayeur.exe - 7 error(s), 0 warning(s)

d'pres que j'ai compris c'est que les erreurs se trouvent dans ccDll_TestDlg, olors j'ai essaye de suprime le programme ccDll_TestDlg  j'obtient  0  erreurs
voici  mon programme:

<li>ccDLL_TestDlg.cpp
</li>// ccDLL_TestDlg.cpp
//

#include "stdafx.h"
#include "ccDLL_Test.h"
#include "ccDLL_TestDlg.h"
#include "ccDLL_CoinSelector.h"
#include "ccDLL_Peripheral.h"
#include "ccDLL_BillValidator.h"
#include "ccDLL_Payout.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CAboutDlg-Dialogfeld für Anwendungsbefehl "Info"

class CAboutDlg : public CDialog
{
public:
    CAboutDlg();

// Dialogfelddaten
    enum  {IDD=  IDD_ABOUTBOX };

    protected:
 void DoDataExchange(CDataExchange* pDX);    // DDX/DDV-Unterstützung

// Implementierung
protected:
    DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// CcDLL_TestDlg-Dialogfeld

ccDLL_TestDlg::ccDLL_TestDlg(CWnd* pParent /*=NULL*/)
    : CDialog(ccDLL_TestDlg::IDD, pParent)
    , m_ComPort(2)
    , m_CommResult(0)
    , m_ccTalkAddress(0)
    , m_ccTalkResult(0)
    , m_Category(_T(""))
    , m_Manufacturer(_T(""))
    , m_Product(_T(""))
    , m_Version(_T(""))
    , m_Serial(_T(""))
    , m_PIN(_T("123456"))
{
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void ccDLL_TestDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Text(pDX, IDC_EDIT1, m_ComPort);
    DDX_Text(pDX, IDC_EDIT2, m_CommResult);
    DDX_Text(pDX, IDC_EDIT3, m_ccTalkAddress);
    DDX_Text(pDX, IDC_EDIT4, m_ccTalkResult);
    DDX_Text(pDX, IDC_EDIT5, m_Category);
    DDX_Text(pDX, IDC_EDIT7, m_Manufacturer);
    DDX_Text(pDX, IDC_EDIT6, m_Product);
    DDX_Text(pDX, IDC_EDIT8, m_Version);
    DDX_Text(pDX, IDC_EDIT9, m_Serial);
    DDX_Control(pDX, IDC_BTNCOINSELECTOR, m_btnCoinSelector);
    DDX_Control(pDX, IDC_BTNPAYOUT, m_btnPayout);
    DDX_Control(pDX, IDC_BTNPERIPHERAL, m_btnPeripheral);
    DDX_Control(pDX, IDC_BTNBILLVALIDATOR, m_btnBillValidator);
    DDX_Control(pDX, IDC_BUTTON1, m_btnOpen);
    DDX_Control(pDX, IDC_BUTTON2, m_btnClose);
    DDX_Control(pDX, IDC_BUTTON3, m_btnTest);
    DDX_Control(pDX, IDC_COMBO1, m_cbxChecksum);
    DDX_Control(pDX, IDC_BUTTON4, m_btnSendBreak);
    DDX_Control(pDX, IDC_COMBO3, m_cbxAddressList);
    DDX_Control(pDX, IDC_COMBO3, m_cbxAddressList);
    DDX_Control(pDX, IDC_BUTTON5, m_btnAddressPoll);
    DDX_Control(pDX, IDC_COMBO4, m_cbxEncryption);
    DDX_Text(pDX, IDC_EDIT18, m_PIN);
    DDX_Text(pDX, IDC_EDIT18, m_PIN);
    DDX_Control(pDX, IDC_COMBO4, m_cbxEncryption);
}

BEGIN_MESSAGE_MAP(ccDLL_TestDlg, CDialog)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    //}}AFX_MSG_MAP
    ON_BN_CLICKED(IDC_BUTTON1, ccDLL_TestDlg::OnBnClickedButton1)
    ON_BN_CLICKED(IDC_BUTTON2, ccDLL_TestDlg::OnBnClickedButton2)
    ON_BN_CLICKED(IDC_BUTTON3, ccDLL_TestDlg::OnBnClickedButton3)
    ON_BN_CLICKED(IDC_BTNCOINSELECTOR, ccDLL_TestDlg::OnBnClickedBtncoinselector)
    ON_BN_CLICKED(IDC_BTNPAYOUT, ccDLL_TestDlg::OnBnClickedBtnpayout)
    ON_BN_CLICKED(IDC_BTNPERIPHERAL, ccDLL_TestDlg::OnBnClickedBtnperipheral)
    ON_BN_CLICKED(IDC_BTNBILLVALIDATOR, ccDLL_TestDlg::OnBnClickedBtnbillvalidator)
    ON_BN_CLICKED(IDC_BUTTON4, ccDLL_TestDlg::OnBnClickedButton4)
    ON_BN_CLICKED(IDC_BUTTON5, ccDLL_TestDlg::OnBnClickedButton5)
END_MESSAGE_MAP()

// CcDLL_TestDlg-Meldungshandler

const CCTALK_ADDRESSLIST defaddrlst =     { 2, 3, 4, 5, 6, 8, 40, 80, 150 };

BOOL ccDLL_TestDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Hinzufügen des Menübefehls "Info..." zum Systemmenü.

    // IDM_ABOUTBOX muss sich im Bereich der Systembefehle befinden.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        CString strAboutMenu;
        strAboutMenu.LoadString(IDS_ABOUTBOX);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }

    // Symbol für dieses Dialogfeld festlegen. Wird automatisch erledigt
    //  wenn das Hauptfenster der Anwendung kein Dialogfeld ist
    SetIcon(m_hIcon, TRUE);            // Großes Symbol verwenden
    SetIcon(m_hIcon, FALSE);        // Kleines Symbol verwenden

    // Initialise ccTalk classes
    pCcComm = new CcTalkCommunication();
    pCcDev = new CcTalkDevice(pCcComm);
    pCcSel = new CCoinSelector(pCcComm);
    pCcPeri = new CPeripheral(pCcComm);
    pCcPot = new CPayout(pCcComm);
    pCcVal = new CBillValidator(pCcComm);

    EnableButtons(CCCAT_UNKNOWN);

    m_cbxChecksum.AddString("Simple8");
    m_cbxChecksum.AddString("CRC16");
    m_cbxChecksum.SetCurSel(0);

    m_cbxEncryption.AddString("None");
    m_cbxEncryption.AddString("MC BNV");
    m_cbxEncryption.SetCurSel(0);

    ShowAdresses(defaddrlst);

    return TRUE;  // Geben Sie TRUE zurück, außer ein Steuerelement soll den Fokus erhalten
}

void ccDLL_TestDlg::ShowAdresses(CCTALK_ADDRESSLIST addrlst)
{
    CString lstitm;

    m_cbxAddressList.ResetContent();
    for (int i = 0; i < addrlst.Count; i++)
    {
        lstitm.Format("%03d", addrlst.Adresses[i]);
        m_cbxAddressList.AddString(lstitm);
    }
    if (addrlst.Count > 6)
        m_cbxAddressList.SetCurSel(6);
    else
        m_cbxAddressList.SetCurSel(0);
}

void ccDLL_TestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}

// Wenn Sie dem Dialogfeld eine Schaltfläche "Minimieren" hinzufügen, benötigen Sie
//  den nachstehenden Code, um das Symbol zu zeichnen. Für MFC-Anwendungen, die das
//  Dokument/Ansicht-Modell verwenden, wird dies automatisch ausgeführt.

void ccDLL_TestDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // Gerätekontext zum Zeichnen

        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

        // Symbol in Clientrechteck zentrieren
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // Symbol zeichnen
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

// Die System ruft diese Funktion auf, um den Cursor abzufragen, der angezeigt wird, während der Benutzer
//  das minimierte Fenster mit der Maus zieht.
HCURSOR ccDLL_TestDlg::OnQueryDragIcon()
{
    return static_cast<HCURSOR>(m_hIcon);
}

// Try to open the com port
void ccDLL_TestDlg::OnBnClickedButton1()
{
    int comport, res;

    UpdateData(1);
    comport = m_ComPort;
    res = pCcComm->OpenComm(comport);
    m_CommResult = res;
    UpdateData(0);
    EnableButtons(CCCAT_UNKNOWN);

}
// Send Break
void ccDLL_TestDlg::OnBnClickedButton4()
{
    pCcComm->SendBreak();
}
// Try to close the com port
void ccDLL_TestDlg::OnBnClickedButton2()
{
    int res;

    res = pCcComm->CloseComm();
    m_CommResult = res;
    UpdateData(0);
    EnableButtons(CCCAT_UNKNOWN);
}

// Get core info
void ccDLL_TestDlg::OnBnClickedButton3()
{
    int res, addr;
    char cbxtxt[32];
    CCTALK_COREINFO coreinf;
    CCTALK_COINS money;

    UpdateData(1);

    m_cbxAddressList.GetLBText(m_cbxAddressList.GetCurSel(), cbxtxt);
    // Read and set up comm parameters
    sscanf(cbxtxt, "%d", &addr);                    // Device address
    pCcDev->SetDeviceAddress(addr);
    if (m_cbxChecksum.GetCurSel() == 0)                // Checksum type
        pCcDev->SetChecksumType(CSUM_SIMPLE8);
    else
        pCcDev->SetChecksumType(CSUM_CRC16);
    if (m_cbxEncryption.GetCurSel() == 0)            // Encryption
        pCcDev->SetEncryption(ENCRYPT_NONE);
    else
        pCcDev->SetEncryption(ENCRYPT_MCBNV);

    LPTSTR pinbff = m_PIN.GetBuffer(0);
    if (m_PIN.GetLength() == 6)        for (int i 0; i < 6; i++) m_pin[i] pinbff[i] - '0';
    else        for (int i 0; i < 6; i++) m_pin[i] 0;
    pCcDev->InitPINCode(m_pin);

    res = pCcDev->GetCoreInfo(&coreinf);
    m_ccTalkResult = res;
    if (res == CCERR_OK)
    {
        m_Category.Format("%s (%d)", coreinf.Category.Name, coreinf.Category.ID);
        m_Manufacturer = coreinf.Manufacturer;
        m_Product = coreinf.ProductCode;
        m_Version = coreinf.SoftwareRevision;
        m_Serial.Format("%010d", coreinf.Serial);
        if (coreinf.Category.ID == CCCAT_COINSELECTOR)
        {
            res = pCcSel->GetCoinStatus(money);
        }
    }
    else
    {
        m_Category = "";
        m_Manufacturer = "";
        m_Product = "";
        m_Version = "";
        m_Serial = "";
    }
    UpdateData(0);
    EnableButtons(coreinf.Category.ID);
}

// Enable buttons depending on device category
void ccDLL_TestDlg::EnableButtons(int devcat)
{
    m_btnCoinSelector.EnableWindow(0);
    m_btnPayout.EnableWindow(0);
    m_btnPeripheral.EnableWindow(0);
    m_btnBillValidator.EnableWindow(0);
    m_btnOpen.EnableWindow(!pCcComm->GetIsOpen());
    m_btnClose.EnableWindow(pCcComm->GetIsOpen());
    m_btnTest.EnableWindow(pCcComm->GetIsOpen());
    m_btnSendBreak.EnableWindow(pCcComm->GetIsOpen());
    m_btnAddressPoll.EnableWindow(pCcComm->GetIsOpen());

    switch (devcat)
    {
    case CCCAT_COINSELECTOR:
        m_btnCoinSelector.EnableWindow(1);
        break;
    case CCCAT_PAYOUT:
        m_btnPayout.EnableWindow(1);
        break;
    case CCCAT_PERIPHERAL:
        m_btnPeripheral.EnableWindow(1);
        break;
    case CCCAT_BILLVALIDATOR:
        m_btnBillValidator.EnableWindow(1);
        break;
    }
}
// Show coin selector
void ccDLL_TestDlg::OnBnClickedBtncoinselector()
{
    ccDLL_CoinSelector cselDlg;

    UpdateData(1);
    pCcSel->SetDeviceAddress(pCcDev->GetDeviceAddress());
    cselDlg.m_pCcSel = pCcSel;
    cselDlg.DoModal();
}
// Show payout
void ccDLL_TestDlg::OnBnClickedBtnpayout()
{
    ccDLL_Payout potDlg;

    UpdateData(1);
    pCcPot->SetDeviceAddress(pCcDev->GetDeviceAddress());
    potDlg.m_pCcPot = pCcPot;
    potDlg.DoModal();
}
// Show peripheral
void ccDLL_TestDlg::OnBnClickedBtnperipheral()
{
    ccDLL_Peripheral periDlg;

    UpdateData(1);
    pCcPeri->SetDeviceAddress(pCcDev->GetDeviceAddress());
    periDlg.m_pCcPeri = pCcPeri;
    periDlg.DoModal();
}
// Show Bill validator
void ccDLL_TestDlg::OnBnClickedBtnbillvalidator()
{
    ccDLL_BillValidator valDlg;

    UpdateData(1);
    pCcVal->SetDeviceAddress(pCcDev->GetDeviceAddress());
    pCcVal->SetChecksumType(pCcDev->GetChecksumType());
    pCcVal->SetEncryption(pCcDev->GetEncryption());
    pCcVal->InitPINCode(m_pin);
    valDlg.m_pCcVal = pCcVal;
    valDlg.DoModal();
}

// Address poll
void ccDLL_TestDlg::OnBnClickedButton5()
{
    CCTALK_ADDRESSLIST addrlst;
    CCTALK_COMMPARS commpars;

    int res = CCERR_UNKNOWN;

    if (m_cbxChecksum.GetCurSel() == 0)
        commpars.ChecksumType = CSUM_SIMPLE8;
    else
        commpars.ChecksumType = CSUM_CRC16;

    res = pCcComm->AddressPoll(&addrlst, commpars);

    if (res == CCERR_OK)
        ShowAdresses(addrlst);

    m_ccTalkResult = res;
    UpdateData(0);
}

<li>ccDLL_TestDlg.h
</li> #pragma once

#include ".\ccTalkComm.h"
#include "afxwin.h"

class ccDLL_TestDlg:public CDialog

{
    DECLARE_DYNAMIC(ccDLL_TestDlg)
public :
    ccDLL_TestDlg(CWnd* pParent=NULL);
    enum cust_enum{};
        enum {IDD=IDD_ccDLL_Test_DIALOG};
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
    HICON m_hIcon;
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID,LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedButton1();
    afx_msg void OnBnClickedButton2();
    CcTalkCommunication* pCcComm;
    CcTalkDevice* pCcDev;
    CCoinSelector* pCcSel;
    CPeripheral* pCcPeri;
    CPayout* pCcPot;
    CBillValidator* pCcVal;

    BYTE m_pin[6];

private:
    void ShowAdresses(CCTALK_ADDRESSLIST addrlst);

public:
        void ccDLL_TestDlg::EnableButtons(int devcat);

    int m_ComPort;
    int m_CommResult;
    int m_ccTalkAddress;
    int m_ccTalkResult;
    afx_msg void OnBnClickedButton3();
    CString m_Category;
    CString m_Manufacturer;
    CString m_Product;
    CString m_Version;
    CString m_Serial;
    afx_msg void OnBnClickedButton5();
    CButton m_btnCoinSelector;
    CButton m_btnPayout;
    CButton m_btnPeripheral;
    CButton m_btnBillValidator;
    CButton m_btnOpen;
    CButton m_btnClose;
    CButton m_btnTest;
    afx_msg void OnBnClickedBtncoinselector();
    afx_msg void OnBnClickedBtnpayout();
    afx_msg void OnBnClickedBtnperipheral();
    afx_msg void OnBnClickedBtnbillvalidator();
    CComboBox m_cbxChecksum;
    afx_msg void OnBnClickedButton4();
    CButton m_btnSendBreak;
    CComboBox m_cbxAddressList;
    CButton m_btnAddressPoll;
    CString m_PIN;
    CComboBox m_cbxEncryption;

};
svp aider moi
merci d'avance

1 réponse

Messages postés
1107
Date d'inscription
mercredi 15 juin 2011
Statut
Membre
Dernière intervention
10 juillet 2018
4
tu n'auras pas défini une classe CAboutDlg dans le fichier Monnayeur.cpp ?