[Programmation] undefined symbol error
Répondre à la discussion
Affichage des résultats 1 à 8 sur 8

undefined symbol error



  1. #1
    Bastien59

    undefined symbol error


    ------

    Bonjour à toutes et à tous,

    Dans le cadre d'un changement de compilateur, je rencontre une erreur que je n'arrive pas à résoudre pour la migration de mon projet.
    Le projet en question est en langage c, et se fait du compilateur C18 vers le compilateur XC8 de microchip.
    J'utilise la version de MPLab X IDE 3.26, compilateur XC8 v1.37 PRO

    Voici l'erreur en question :

    Code:
    :0: error: (499) undefined symbol:
    	_vMBPortClose(dist/default/production/BNE-DEV-SFW-021.X.production.obj) 
    (908) exit status = 1
    La fonction "vMBPortClose" est définie dans le fichier mbport.h (librairie microchip) :

    Code:
    #ifndef _MB_PORT_H
    #define _MB_PORT_H
    
    #ifdef __cplusplus
    PR_BEGIN_EXTERN_C
    #endif
    
    #include <xc.h>
    
    /* ----------------------- Type definitions ---------------------------------*/
    
    typedef enum
    {
        EV_READY,                   /*!< Startup finished. */
        EV_FRAME_RECEIVED,          /*!< Frame received. */
        EV_EXECUTE,                 /*!< Execute function. */
        EV_FRAME_SENT               /*!< Frame sent. */
    } eMBEventType;
    
    /*! \ingroup modbus
     * \brief Parity used for characters in serial mode.
     *
     * The parity which should be applied to the characters sent over the serial
     * link. Please note that this values are actually passed to the porting
     * layer and therefore not all parity modes might be available.
     */
    typedef enum
    {
        MB_PAR_NONE,                /*!< No parity. */
        MB_PAR_ODD,                 /*!< Odd parity. */
        MB_PAR_EVEN                 /*!< Even parity. */
    } eMBParity;
    
    /* ----------------------- Supporting functions -----------------------------*/
    BOOL            xMBPortEventInit( void );
    
    BOOL            xMBPortEventPost( eMBEventType eEvent );
    
    BOOL            xMBPortEventGet(  /*@out@ */ eMBEventType * eEvent );
    
    /* ----------------------- Serial port functions ----------------------------*/
    
    BOOL            xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate,
                                       UCHAR ucDataBits, eMBParity eParity );
    
    void            vMBPortClose( void );
    
    void            xMBPortSerialClose( void );
    
    void            vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable );
    
    BOOL            xMBPortSerialGetByte( CHAR * pucByte );
    
    BOOL            xMBPortSerialPutByte( CHAR ucByte );
    
    UCHAR 			CalcParity( UCHAR ucData );
    
    /* ----------------------- Timers functions ---------------------------------*/
    BOOL            xMBPortTimersInit( USHORT usTimeOut50us );
    
    void            xMBPortTimersClose( void );
    
    void            vMBPortTimersEnable( void );
    
    void            vMBPortTimersDisable( void );
    
    void            vMBPortTimersDelay( USHORT usTimeOutMS );
    
    /* ----------------------- Callback for the protocol stack ------------------*/
    
    /*!
     * \brief Callback function for the porting layer when a new byte is
     *   available.
     *
     * Depending upon the mode this callback function is used by the RTU or
     * ASCII transmission layers. In any case a call to xMBPortSerialGetByte()
     * must immediately return a new character.
     *
     * \return <code>TRUE</code> if a event was posted to the queue because
     *   a new byte was received. The port implementation should wake up the
     *   tasks which are currently blocked on the eventqueue.
     */
    extern          BOOL( *pxMBFrameCBByteReceived ) ( void );
    
    extern          BOOL( *pxMBFrameCBTransmitterEmpty ) ( void );
    
    extern          BOOL( *pxMBPortCBTimerExpired ) ( void );
    
    /* ----------------------- TCP port functions -------------------------------*/
    BOOL            xMBTCPPortInit( USHORT usTCPPort );
    
    void            vMBTCPPortClose( void );
    
    void            vMBTCPPortDisable( void );
    
    BOOL            xMBTCPPortGetRequest( UCHAR **ppucMBTCPFrame, USHORT * usTCPLength );
    
    BOOL            xMBTCPPortSendResponse( const UCHAR *pucMBTCPFrame, USHORT usTCPLength );
    
    #ifdef __cplusplus
    PR_END_EXTERN_C
    #endif
    #endif
    Et utilisée dans le fichier "mb.c" (librairie microchip également) :
    Il y a bien un #include "mbport.h"

    Code:
    #define __MB_C
    #include "common.h"
    #if defined(EM2xxL_MBR) || defined(EM2xxL_MBW)
    
    /* ----------------------- System includes ----------------------------------*/
    #include "stdlib.h"
    #include "string.h"
    
    /* ----------------------- Platform includes --------------------------------*/
    #include "port.h"
    
    /* ----------------------- Modbus includes ----------------------------------*/
    #include "mb.h"
    #include "mbconfig.h"
    #include "mbframe.h"
    #include "mbproto.h"
    #include "mbfunc.h"
    
    #include "mbport.h"
    #if MB_RTU_ENABLED > 0
    #include "mbrtu.h"
    #endif
    #if MB_ASCII_ENABLED > 0
    #include "mbascii.h"
    #endif
    #if MB_TCP_ENABLED > 0
    #include "mbtcp.h"
    #endif
    
    #ifndef MB_PORT_HAS_CLOSE
    #define MB_PORT_HAS_CLOSE 0
    #endif
    
    /* ----------------------- Static variables ---------------------------------*/
    
    static UCHAR    ucMBAddress;
    static eMBMode  eMBCurrentMode;
    
    static enum
    {
        STATE_ENABLED,
        STATE_DISABLED,
        STATE_NOT_INITIALIZED
    } eMBState = STATE_NOT_INITIALIZED;
    
    /* Functions pointer which are initialized in eMBInit( ). Depending on the
     * mode (RTU or ASCII) the are set to the correct implementations.
     */
    static peMBFrameSend peMBFrameSendCur;
    static pvMBFrameStart pvMBFrameStartCur;
    static pvMBFrameStop pvMBFrameStopCur;
    static peMBFrameReceive peMBFrameReceiveCur;
    static pvMBFrameClose pvMBFrameCloseCur;
    
    /* Callback functions required by the porting layer. They are called when
     * an external event has happend which includes a timeout or the reception
     * or transmission of a character.
     */
    BOOL( *pxMBFrameCBByteReceived ) ( void );
    BOOL( *pxMBFrameCBTransmitterEmpty ) ( void );
    BOOL( *pxMBPortCBTimerExpired ) ( void );
    
    BOOL( *pxMBFrameCBReceiveFSMCur ) ( void );
    BOOL( *pxMBFrameCBTransmitFSMCur ) ( void );
    
    /* An array of Modbus functions handlers which associates Modbus function
     * codes with implementing functions.
     */
    
    xMBFunctionHandler xFuncHandlers[MB_FUNC_HANDLERS_MAX] = {
    #if MB_FUNC_OTHER_REP_SLAVEID_ENABLED > 0
        {MB_FUNC_OTHER_REPORT_SLAVEID, eMBFuncReportSlaveID},
    #endif
    #if MB_FUNC_READ_INPUT_ENABLED > 0
        {MB_FUNC_READ_INPUT_REGISTER, eMBFuncReadInputRegister},
    #endif
    #if MB_FUNC_READ_HOLDING_ENABLED > 0
        {MB_FUNC_READ_HOLDING_REGISTER, eMBFuncReadHoldingRegister},
    #endif
    #if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0
        {MB_FUNC_WRITE_MULTIPLE_REGISTERS, eMBFuncWriteMultipleHoldingRegister},
    #endif
    #if MB_FUNC_WRITE_HOLDING_ENABLED > 0
        {MB_FUNC_WRITE_REGISTER, eMBFuncWriteHoldingRegister},
    #endif
    #if MB_FUNC_READWRITE_HOLDING_ENABLED > 0
        {MB_FUNC_READWRITE_MULTIPLE_REGISTERS, eMBFuncReadWriteMultipleHoldingRegister},
    #endif
    #if MB_FUNC_READ_COILS_ENABLED > 0
        {MB_FUNC_READ_COILS, eMBFuncReadCoils},
    #endif
    #if MB_FUNC_WRITE_COIL_ENABLED > 0
        {MB_FUNC_WRITE_SINGLE_COIL, eMBFuncWriteCoil},
    #endif
    #if MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED > 0
        {MB_FUNC_WRITE_MULTIPLE_COILS, eMBFuncWriteMultipleCoils},
    #endif
    #if MB_FUNC_READ_DISCRETE_INPUTS_ENABLED > 0
        {MB_FUNC_READ_DISCRETE_INPUTS, eMBFuncReadDiscreteInputs},
    #endif
    };
    
    /* ----------------------- Start implementation -----------------------------*/
    eMBErrorCode
    eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
    {
        eMBErrorCode    eStatus = MB_ENOERR;
    
        /* check preconditions */
        if( ( ucSlaveAddress == MB_ADDRESS_BROADCAST ) ||
            ( ucSlaveAddress < MB_ADDRESS_MIN ) || ( ucSlaveAddress > MB_ADDRESS_MAX ) )
        {
            eStatus = MB_EINVAL;
        }
        else
        {
            ucMBAddress = ucSlaveAddress;
    
            switch ( eMode )
            {
    #if MB_RTU_ENABLED > 0
            case MB_RTU:
                pvMBFrameStartCur = eMBRTUStart;
                pvMBFrameStopCur = eMBRTUStop;
                peMBFrameSendCur = eMBRTUSend;
                peMBFrameReceiveCur = eMBRTUReceive;
                pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
                pxMBFrameCBByteReceived = xMBRTUReceiveFSM;
                pxMBFrameCBTransmitterEmpty = xMBRTUTransmitFSM;
                pxMBPortCBTimerExpired = xMBRTUTimerT35Expired;
    
                eStatus = eMBRTUInit( ucMBAddress, ucPort, ulBaudRate, eParity );
                break;
    #endif
    #if MB_ASCII_ENABLED > 0
            case MB_ASCII:
                pvMBFrameStartCur = eMBASCIIStart;
                pvMBFrameStopCur = eMBASCIIStop;
                peMBFrameSendCur = eMBASCIISend;
                peMBFrameReceiveCur = eMBASCIIReceive;
                pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
                pxMBFrameCBByteReceived = xMBASCIIReceiveFSM;
                pxMBFrameCBTransmitterEmpty = xMBASCIITransmitFSM;
                pxMBPortCBTimerExpired = xMBASCIITimerT1SExpired;
    
                eStatus = eMBASCIIInit( ucMBAddress, ucPort, ulBaudRate, eParity );
                break;
    #endif
            default:
                eStatus = MB_EINVAL;
            }
    
            if( eStatus == MB_ENOERR )
            {
                if( !xMBPortEventInit(  ) )
                {
                    /* port dependent event module initalization failed. */
                    eStatus = MB_EPORTERR;
                }
                else
                {
                    eMBCurrentMode = eMode;
                    eMBState = STATE_DISABLED;
                }
            }
        }
        return eStatus;
    }
    Voilà je n'arrive pas à compiler, à part en commentant les lignes où sont utilisé la fonction ce qui n'est pas la solution, ça fait plusieurs jours que je bloque la dessus.
    Je suis interessé par n'importe qu'elle petite piste / astuce / aide.

    Merci d'avance

    -----
    Dernière modification par Bastien59 ; 25/04/2016 à 14h04.

  2. #2
    Bastien59

    Re : undefined symbol error

    [UP]

    Voici ce que dit Microchip dans sa doc à propos de l'erreur

    (499) undefined symbol: (Assembler, Linker)
    The symbol following is undefined at link time. This could be due to spelling error, or
    failure to link an appropriate module.
    Ce n'est pas une erreur de spelling c'est sûr, j'ai bien compris que c'est un problème de linker, mais je ne sais pas pourquoi ...

  3. #3
    Jack
    Modérateur

    Re : undefined symbol error

    Tu peux montrer la ligne où tu fais l'appel de cette fonction?

  4. #4
    Bastien59

    Re : undefined symbol error

    Salut Jack,

    Je fais appel à cette fonction dans le fichier mbport.h : (j'ai essayé de la mettre en évidence dans mon premier post, 3ème section de code, gras + taille 3 mais ça n'a pas suffi peut être)

    Code:
    /* ----------------------- Start implementation -----------------------------*/
    eMBErrorCode
    eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
    {
        eMBErrorCode    eStatus = MB_ENOERR;
    
        /* check preconditions */
        if( ( ucSlaveAddress == MB_ADDRESS_BROADCAST ) ||
            ( ucSlaveAddress < MB_ADDRESS_MIN ) || ( ucSlaveAddress > MB_ADDRESS_MAX ) )
        {
            eStatus = MB_EINVAL;
        }
        else
        {
            ucMBAddress = ucSlaveAddress;
    
            switch ( eMode )
            {
    #if MB_RTU_ENABLED > 0
            case MB_RTU:
                pvMBFrameStartCur = eMBRTUStart;
                pvMBFrameStopCur = eMBRTUStop;
                peMBFrameSendCur = eMBRTUSend;
                peMBFrameReceiveCur = eMBRTUReceive;
                pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
                pxMBFrameCBByteReceived = xMBRTUReceiveFSM;
                pxMBFrameCBTransmitterEmpty = xMBRTUTransmitFSM;
                pxMBPortCBTimerExpired = xMBRTUTimerT35Expired;
    
                eStatus = eMBRTUInit( ucMBAddress, ucPort, ulBaudRate, eParity );
                break;
    #endif
    #if MB_ASCII_ENABLED > 0
            case MB_ASCII:
                pvMBFrameStartCur = eMBASCIIStart;
                pvMBFrameStopCur = eMBASCIIStop;
                peMBFrameSendCur = eMBASCIISend;
                peMBFrameReceiveCur = eMBASCIIReceive;
                pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
                pxMBFrameCBByteReceived = xMBASCIIReceiveFSM;
                pxMBFrameCBTransmitterEmpty = xMBASCIITransmitFSM;
                pxMBPortCBTimerExpired = xMBASCIITimerT1SExpired;
    
                eStatus = eMBASCIIInit( ucMBAddress, ucPort, ulBaudRate, eParity );
                break;
    #endif
            default:
                eStatus = MB_EINVAL;
            }
    
            if( eStatus == MB_ENOERR )
            {
                if( !xMBPortEventInit(  ) )
                {
                    /* port dependent event module initalization failed. */
                    eStatus = MB_EPORTERR;
                }
                else
                {
                    eMBCurrentMode = eMode;
                    eMBState = STATE_DISABLED;
                }
            }
        }
        return eStatus;
    }

  5. A voir en vidéo sur Futura
  6. #5
    Jack
    Modérateur

    Re : undefined symbol error

    Ca n'est pas vraiment l'appel de la fonction, mais l'affectation de l'adresse du début de la fonction à un pointeur.

    Dans ton IDE, il n'y a pas moyen de demander où est effectuée sa déclaration en effectuant un clic droit sur vMBPortClose?

  7. #6
    Bastien59

    Re : undefined symbol error

    Citation Envoyé par Jack Voir le message
    Dans ton IDE, il n'y a pas moyen de demander où est effectuée sa déclaration en effectuant un clic droit sur vMBPortClose?
    Oui j'ai une option "Go to Declaration/Definition" qui me renvoi au fichier mbport.h là où la fonction est déclarée

  8. #7
    Jack
    Modérateur

    Re : undefined symbol error

    Je ne connais pas ton IDE, mais de manière générale, la simple présence du fichier ne suffit pas toujours. Il faut donc peut-être déclarer (inclure) le fichier dans le gestionnaire de projet.

  9. #8
    Bastien59

    Re : undefined symbol error

    Merci beaucoup, le fichier en question n'était en effet pas inclus dans le projet, et le linker ne le trouvais pas

Discussions similaires

  1. IOS : undefined symbols for architecture i386
    Par Adryyy dans le forum Programmation et langages, Algorithmique
    Réponses: 0
    Dernier message: 23/08/2014, 14h48
  2. (PHP) Problème Notice: Undefined index
    Par ycouton dans le forum Programmation et langages, Algorithmique
    Réponses: 10
    Dernier message: 25/03/2014, 17h06
  3. Bug Word 2007 - police Symbol
    Par MrSeb dans le forum Logiciel - Software - Open Source
    Réponses: 0
    Dernier message: 15/04/2010, 13h59
  4. MPLAB : P16F688.INC 182 : Missing symbol
    Par Toufinet dans le forum Électronique
    Réponses: 1
    Dernier message: 04/08/2007, 21h04
  5. Notice: Undefined variable
    Par invite13150ddf dans le forum Logiciel - Software - Open Source
    Réponses: 0
    Dernier message: 16/10/2006, 16h21
Découvrez nos comparatifs produits sur l'informatique et les technologies.