Autor Tema: [SOLUCIONADO]Problema al compilar mi proyecto con MPLAB y C18  (Leído 3439 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Thulsa Doom

  • PIC24F
  • *****
  • Mensajes: 771
    • https://electronicadicto.wordpress.com/
[SOLUCIONADO]Problema al compilar mi proyecto con MPLAB y C18
« en: 27 de Octubre de 2012, 08:35:48 »
Hola a todos, pues el MPLAB me da un error que no se que es, si dejo  el main solo sin nada dentro, no me da error y me compila.

Estoy utilizando las librerías TCP/IP de microchip para adaptarla a un PIC18F4550 e utilizo C18 de compilador.

El error que me da es este:

Código: [Seleccionar]
MPLINK 4.44, Linker
Device Database Version 1.9
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - could not find definition of symbol 'BerkeleyUDPClientDemo' in file 'Objects\MainNestor.o'.
Errors    : 1  
Link step failed.

Resulta que la función a la que se refiere está definida en el main.h aunque dentro de la función no tenga código.

Me he fijado en algún proyecto que han colgado los compañeros y esos proyectos si me compilan sin problemas, y tienen la misma función de la misma manera que en el mio, pero el que estoy intentando yo no deja de salir esos errores, si quito las funciones del main.c me salen otras distintas, es un no acabar.

Tengo las rutas a los directorios seleccionadas en el Project > Build Options > Project > Directories.
A ver si hay alguna ayudita
« Última modificación: 28 de Octubre de 2012, 16:40:37 por Thulsa Doom »
Más códigos y desarrollos en https://electronicadicto.wordpress.com/ date una vuelta y curiosea un rato...

Desconectado jukinch

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 608
Re: Problema al compilar mi proyecto con MPLAB y C18
« Respuesta #1 en: 27 de Octubre de 2012, 09:01:13 »
Hola thulsadoom. Muestra los #includes como los tienes en el código de mainnestor.
Y también los paths de configuración del proyecto.
"Divide las dificultades que examinas en tantas partes como sea posible para su mejor solución." -René Descartes

Desconectado Thulsa Doom

  • PIC24F
  • *****
  • Mensajes: 771
    • https://electronicadicto.wordpress.com/
Re: Problema al compilar mi proyecto con MPLAB y C18
« Respuesta #2 en: 27 de Octubre de 2012, 10:10:00 »
Te pongo el .h y el .c

Código: [Seleccionar]
* Author               Date    Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * E. Wood 4/26/08 Copied from MainDemo.c
 ********************************************************************/
#ifndef _MAINNESTOR_H
#define _MAINNESTOR_H

#define BAUD_RATE       (19200) // bps

#if !defined(THIS_IS_STACK_APPLICATION)
extern BYTE AN0String[8];
#endif

void DoUARTConfig(void);

#if defined(EEPROM_CS_TRIS) || defined(SPIFLASH_CS_TRIS)
void SaveAppConfig(const APP_CONFIG *AppConfig);
#else
#define SaveAppConfig(a)
#endif

void SMTPDemo(void);
void PingDemo(void);
void SNMPTrapDemo(void);
void SNMPV2TrapDemo(void);
void GenericTCPClient(void);
void GenericTCPServer(void);
void BerkeleyTCPClientDemo(void);
void BerkeleyTCPServerDemo(void);
void BerkeleyUDPClientDemo(void);


// Define a header structure for validating the AppConfig data structure in EEPROM/Flash
typedef struct
{
unsigned short wConfigurationLength; // Number of bytes saved in EEPROM/Flash (sizeof(APP_CONFIG))
unsigned short wOriginalChecksum; // Checksum of the original AppConfig defaults as loaded from ROM (to detect when to wipe the EEPROM/Flash record of AppConfig due to a stack change, such as when switching from Ethernet to Wi-Fi)
unsigned short wCurrentChecksum; // Checksum of the current EEPROM/Flash data.  This protects against using corrupt values if power failure occurs while writing them and helps detect coding errors in which some other task writes to the EEPROM in the AppConfig area.
} NVM_VALIDATION_STRUCT;


// An actual function defined in MainDemo.c for displaying the current IP
// address on the UART and/or LCD.
void DisplayIPValue(IP_ADDR IPVal);


#endif // _MAINNESTOR_H

Código: [Seleccionar]
* ----  -----------------------------------------
 * 1.0   Initial release
 * V5.36 ---- STACK_USE_MPFS support has been removed
 ********************************************************************/
/*
 * This macro uniquely defines this file as the main entry point.
 * There should only be one such definition in the entire project,
 * and this file must define the AppConfig variable as described below.
 */
#define THIS_IS_STACK_APPLICATION
#define ENC28J60

// Include all headers for any enabled TCPIP Stack functions
#include "TCPIP Stack/TCPIP.h"

// Include functions specific to this stack application
#include "MainNestor.h"

#if defined(STACK_USE_ZEROCONF_LINK_LOCAL)
#include "TCPIP Stack/ZeroconfLinkLocal.h"
#endif
#if defined(STACK_USE_ZEROCONF_MDNS_SD)
#include "TCPIP Stack/ZeroconfMulticastDNS.h"
#endif

#ifdef USE_USB_INTERFACE
#include "USB/usb.h"
#include "USB/usb_host_msd.h"
#include "USB/usb_host_msd_scsi.h"
#endif

// Declare AppConfig structure and some other supporting stack variables
APP_CONFIG AppConfig;
BYTE AN0String[8];



// Private helper functions.
// These may or may not be present in all applications.
//static void InitAppConfig(void);
static void InitializeBoard(void);
//static void ProcessIO(void);


void main(void){
static DWORD t = 0;
static DWORD dwLastIP = 0;

// Initialize application specific hardware
InitializeBoard();

// Initialize stack-related hardware components that may be
// required by the UART configuration routines
    TickInit();
#if defined(STACK_USE_MPFS) || defined(STACK_USE_MPFS2)
MPFSInit();
#endif

// Initialize Stack and application related NV variables into AppConfig.
// InitAppConfig();

// Initialize core stack layers (MAC, ARP, TCP, UDP) and
// application modules (HTTP, SNMP, etc.)
    StackInit();

// Initialize any application-specific modules or functions/
// For this demo application, this only includes the
// UART 2 TCP Bridge
#if defined(STACK_USE_UART2TCP_BRIDGE)
UART2TCPBridgeInit();
#endif

// Now that all items are initialized, begin the co-operative
// multitasking loop.  This infinite loop will continuously
// execute all stack-related tasks, as well as your own
// application's functions.  Custom functions should be added
// at the end of this loop.
    // Note that this is a "co-operative mult-tasking" mechanism
    // where every task performs its tasks (whether all in one shot
    // or part of it) and returns so that other tasks can do their
    // job.
    // If a task needs very long time to do its job, it must be broken
    // down into smaller pieces so that other tasks can have CPU time.
    while(1){
        
        // This task performs normal stack task including checking
        // for incoming packet, type of packet and calling
        // appropriate stack entity to process it.
        StackTask();
        
        // This tasks invokes each of the core stack application tasks
        StackApplications();

// Process application specific tasks here.
// For this demo app, this will include the Generic TCP
// client and servers, and the SNMP, Ping, and SNMP Trap
// demos.  Following that, we will process any IO from
// the inputs on the board itself.
// Any custom modules or processing you need to do should
// go here.
#if defined(STACK_USE_GENERIC_TCP_CLIENT_EXAMPLE)
GenericTCPClient();
#endif

#if defined(STACK_USE_GENERIC_TCP_SERVER_EXAMPLE)
GenericTCPServer();
#endif

#if defined(STACK_USE_SMTP_CLIENT)
SMTPDemo();
#endif

#if defined(STACK_USE_ICMP_CLIENT)
PingDemo();
#endif

#if defined(STACK_USE_SNMP_SERVER) && !defined(SNMP_TRAP_DISABLED)
SNMPTrapDemo();
if(gSendTrapFlag)
SNMPSendTrap();
#endif

#if defined(STACK_USE_BERKELEY_API)
BerkeleyTCPClientDemo();
BerkeleyTCPServerDemo();
BerkeleyUDPClientDemo();
#endif


        // If the local IP address has changed (ex: due to DHCP lease change)
        // write the new IP address to the LCD display, UART, and Announce
        // service
/* if(dwLastIP != AppConfig.MyIPAddr.Val)
{
dwLastIP = AppConfig.MyIPAddr.Val;

#if defined(STACK_USE_UART)
putrsUART((ROM char*)"\r\nNew IP Address: ");
#endif

DisplayIPValue(AppConfig.MyIPAddr);

#if defined(STACK_USE_UART)
putrsUART((ROM char*)"\r\n");
#endif


#if defined(STACK_USE_ANNOUNCE)
AnnounceIP();
#endif
}*/
}

}  



static void InitializeBoard(void){



// LEDs
LedV = 0;
LedR = 1;

// Enable 4x/5x/96MHz PLL on PIC18F87J10, PIC18F97J60, PIC18F87J50, etc.
  // OSCTUNE = 0x40;

// Set up analog features of PORTA

// ADCON0 = 0x01; // ADON, Channel 0
// ADCON1 = 0x0E; // Vdd/Vss is +/-REF, AN0 is analog
// ADCON2 = 0xBE; // Right justify, 20TAD ACQ time, Fosc/64 (~21.0kHz)
   // Enable internal PORTB pull-ups
   INTCON2bits.RBPU = 0;

// Configure USART
   TXSTA = 0x20;
   RCSTA = 0x90;

// See if we can use the high baud rate setting
#if (((GetPeripheralClock()+2*BAUD_RATE)/BAUD_RATE/4 - 1) <= 255)
SPBRG = (GetPeripheralClock()+2*BAUD_RATE)/BAUD_RATE/4 - 1;
TXSTAbits.BRGH = 1;
#else // Use the low baud rate setting
SPBRG = (GetPeripheralClock()+8*BAUD_RATE)/BAUD_RATE/16 - 1;
#endif


// Enable Interrupts
RCONbits.IPEN = 1; // Enable interrupt priorities
   INTCONbits.GIEH = 1;
   INTCONbits.GIEL = 1;

   /* ADCON0bits.ADCAL = 1;
ADCON0bits.GO = 1;
while(ADCON0bits.GO);
ADCON0bits.ADCAL = 0;
*/
#if defined(SPIRAM_CS_TRIS)
SPIRAMInit();
#endif
#if defined(EEPROM_CS_TRIS)
XEEInit();
#endif
#if defined(SPIFLASH_CS_TRIS)
SPIFlashInit();
#endif

y las rutas:
 en Out Put directory
pues a la carpeta donde quiero que salgan los archivos compilados, esa carpeta está dentro del proyecto.

en Intermediary directory:
en una carpeta llamada Objets creada dentro de la carpeta de mi proyecto

en Includer search path:
  pues al includer donde estan todos los .h de mi proyecto dentro de la carpeta de mi proyecto
  a la carpeta .h del compilador
  y a una carpeta llamada include/tdpip que esta en mi proyecto

en Library search path:
  en la carpeta tcpip stack dentro de mi proyecto
y a la carpeta lib del compilador c18

en Linker-script
  esa a la carpeta lk de compilador

ósera lo que he creado es una copia de la carpeta del stack de microchip pero con los archivos de los stack tcp/ip en otro lugar y he redirigido las rutas, creo que eso está bien peroooo no soy ningún experto mas bien lo contrario.
« Última modificación: 27 de Octubre de 2012, 10:19:46 por Thulsa Doom »
Más códigos y desarrollos en https://electronicadicto.wordpress.com/ date una vuelta y curiosea un rato...

Desconectado jukinch

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 608
Re: Problema al compilar mi proyecto con MPLAB y C18
« Respuesta #3 en: 27 de Octubre de 2012, 11:33:20 »
Que versión de c18 y mplab usas?
Si estás agregando al proyecto un archivo linker y usas una versión actualizada de mplab probá quitar el linker del proyecto.

Lee esta información:
http://www.electro-tech-online.com/microcontrollers/128316-c18-error-could-not-find-definition-symbol-3.html
"Divide las dificultades que examinas en tantas partes como sea posible para su mejor solución." -René Descartes

Desconectado Thulsa Doom

  • PIC24F
  • *****
  • Mensajes: 771
    • https://electronicadicto.wordpress.com/
Re: Problema al compilar mi proyecto con MPLAB y C18
« Respuesta #4 en: 27 de Octubre de 2012, 13:37:18 »
Estoy utilizando el MPLAB 8.87 y el compilador C18 v 3.41

He probado a sacar la ruta del archivo linker, he probado otros linker, he desinstalado el compilador y lo he instalado de nuevo.
Y sigue pasando lo mismo.

Lo raro es que con proyectos ya terminados y colgados en la red, los compilo de nuevo y va perfectamente.

Si hago un proyecto nuevo sencillo tipo encender dos redes, esos proyectos si me los compila bien.

Pero este dichoso proyecto con la maraña de librerías TCP/IP no lo hace, la verdad es que es desesperante y n o me dan ganas de seguir con esto del c18
Más códigos y desarrollos en https://electronicadicto.wordpress.com/ date una vuelta y curiosea un rato...

Desconectado Thulsa Doom

  • PIC24F
  • *****
  • Mensajes: 771
    • https://electronicadicto.wordpress.com/
Re: Problema al compilar mi proyecto con MPLAB y C18
« Respuesta #5 en: 28 de Octubre de 2012, 16:40:15 »
Pues he solucionado el problema, resulta que para que no de esos errores hay que añadir en la ventada del proyecto (la ventana que aparece a la izquierda) todos los drivers del proyecto, ósea todos los .c y los .h.  :z)

No entiendo esto ya que se supone que en la ventana del proyecto están seleccionadas las rutas donde están esos archivos y dentro de las librerías están las llamadas y las rutas de los archivos. ¡¡Que alguien me lo explique!!  :huh: :huh:
Más códigos y desarrollos en https://electronicadicto.wordpress.com/ date una vuelta y curiosea un rato...

Desconectado jukinch

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 608
Re: [SOLUCIONADO]Problema al compilar mi proyecto con MPLAB y C18
« Respuesta #6 en: 28 de Octubre de 2012, 20:53:36 »
Que bueno thulsadoom que lo solucionaste!  :-/
"Divide las dificultades que examinas en tantas partes como sea posible para su mejor solución." -René Descartes


 

anything