Hello,
I get this error when compiling Adam Dunkels uIP adapted to LPC-2124 board. fs.c contains the functions to open files (fs_open) and fsdata.c contains the html code of these files. I'm completely stuck with this, I would apreciate any help.
Thanks.
error log: uIP-2124.axf: Error: L6200E: Symbol file_cgi_files multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_cgi_stats multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_cgi_tcp multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_img_bg_png multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_about_html multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_control_html multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_404_html multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_files_footer_plain multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_files_header_html multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_index_html multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_stats_footer_plain multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_stats_header_html multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_tcp_footer_plain multiply defined (by fsdata.o and fs.o). uIP-2124.axf: Error: L6200E: Symbol file_tcp_header_html multiply defined (by fsdata.o and fs.o).
First of all thank for your reply,
I have been checked in both files (fs.c and fsdata.c) if I had defined the same file_cgi_files in both, but as far i can see I didnÂ't. I know that I only have to declare it in one of them and make a reference as extern-declare in the other. But I canÂ't see where is the mistake because I only define it in fsdata.c
I send the code just in case you donÂ't mind to have a look at it, IÂ've been stuck with it for a week, any help apreciated.
Here is the code of fs.c: #include "uip.h" #include "httpd.h" #include "fs.h" #include "fsdata.h"
#define NULL (void *)0 #include "fsdata.c"
#ifdef FS_STATISTICS #if FS_STATISTICS == 1 static u16_t count[FS_NUMFILES]; #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */
/*-----------------------------------------------------------------------------------*/ static u8_t fs_strcmp(const char *str1, const char *str2) { u8_t i; i = 0; loop:
if(str2[i] == 0 || str1[i] == '\r' || str1[i] == '\n') { return 0; }
if(str1[i] != str2[i]) { return 1; }
++i; goto loop; } /*-----------------------------------------------------------------------------------*/ int fs_open(const char *name, struct fs_file *file) { #ifdef FS_STATISTICS #if FS_STATISTICS == 1 u16_t i = 0; #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */ struct fsdata_file_noconst *f;
for(f = (struct fsdata_file_noconst *)FS_ROOT; f != NULL; f = (struct fsdata_file_noconst *)f->next) {
if(fs_strcmp(name, f->name) == 0) { file->data = f->data; file->len = f->len; #ifdef FS_STATISTICS #if FS_STATISTICS == 1 ++count[i]; #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */ return 1; } #ifdef FS_STATISTICS #if FS_STATISTICS == 1 ++i; #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */
} return 0; } /*-----------------------------------------------------------------------------------*/ void fs_init(void) { #ifdef FS_STATISTICS #if FS_STATISTICS == 1 u16_t i; for(i = 0; i < FS_NUMFILES; i++) { count[i] = 0; } #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */ } /*-----------------------------------------------------------------------------------*/ #ifdef FS_STATISTICS #if FS_STATISTICS == 1 u16_t fs_count (char *name) { struct fsdata_file_noconst *f; u16_t i;
i = 0; for(f = (struct fsdata_file_noconst *)FS_ROOT; f != NULL; f = (struct fsdata_file_noconst *)f->next) {
if(fs_strcmp(name, f->name) == 0) { return count[i]; } ++i; } return 0; } #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */
and fsdata.c code:(only with file_cgi_files definition)
#include "fsdata.h" #define NULL (void *)0 static const char data_cgi_files[] = { /* /cgi/files */ 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0, 0x23, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x63, 0x72}
const struct fsdata_file file_cgi_files[] = {{NULL, data_cgi_files, data_cgi_files + 11, sizeof(data_cgi_files) - 11}};
Please read & follow the instructions for posting source code - and pay attention to the 'Preview'
Attention to detail is key in this game!
"I know that I only have to declare (sic) it in one of them and make a reference as extern-declare in the other."
To be precise, you need to define it exactly once - and then use extern declarations as often as you like elsewhere.
You haven't shown your header's contents - are you sure it doesn't contain a definition...?
Sorry for mistakes,
I am going to check header files carefulle and try to resolve these problems, anyway I post them (headers files) just in case someone can help me:
Thank you so much for your help.
fs.h:
#ifndef __FS_H__ #define __FS_H__ #include "uip.h" /** * An open file in the read-only file system. */ struct fs_file { char *data; /**< The actual file data. */ int len; /**< The length of the file data. */ }; /** * Open a file in the read-only file system. * * \param name The name of the file. * * \param file The file pointer, which must be allocated by caller and * will be filled in by the function. */ int fs_open(const char *name, struct fs_file *file); #ifdef FS_STATISTICS #if FS_STATISTICS == 1 u16_t fs_count(char *name); #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */ /** * Initialize the read-only file system. */ void fs_init(void); #endif /* __FS_H__ */
fsdata.h
#ifndef __FSDATA_H__ #define __FSDATA_H__ #include "uipopt.h" struct fsdata_file { const struct fsdata_file *next; const char *name; const char *data; const int len; #ifdef FS_STATISTICS #if FS_STATISTICS == 1 u16_t count; #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */ }; struct fsdata_file_noconst { struct fsdata_file *next; char *name; char *data; int len; #ifdef FS_STATISTICS #if FS_STATISTICS == 1 u16_t count; #endif /* FS_STATISTICS */ #endif /* FS_STATISTICS */ }; #endif /* __FSDATA_H__ */
"I post them (headers files) just in case someone can help me"
The text "file_cgi_files" occurs nowhere in either of those files - so the problem must, obviously, lie elsewhere...
there must be a way to implement some filter that would prevent posting of a reply/thread is it contains unformatted code...! That will save you so much heart ache, Andy ;-)
I think it would actually be quite hard to make an effective filter that didn't make too many "false hits"...?
But I still say it's symptomatic of an underlying problem: the instructions are very clearly stated; anyone who's being slack enough to miss them - and to not even notice in the preview - has probably also missed important details about their project for the very same reason
As I said earlier, Attention to detail is key in this game!