error Undefined reference to .......

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, 

 

For the last couple days I'm trying to build in a lwip FTP server on FTOS OS, but I'm struggling with a very annoying errors. 

Since I've read two other post here https://www.avrfreaks.net/forum/u... and https://www.avrfreaks.net/forum/i.... I'm trying to figure out what can be the problem, but whitout any progress. I have a undefined reference to a function that are declared already in the header file but still the I'm receiving the same error, perhaps there is something connected with a #ifprotection but I cant understand what is actually an if protection and how that can be a problem. I have alos come across http://faculty.cs.niu.edu/~mcmah... where here is explain the purpose of it but still.....

 

My output 

C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\src\ASF\thirdparty\lwip\lwip-1.4.1\src\include\netif\etharp.h(117,27): warning: packed attribute causes inefficient alignment for 'proto' [-Wattributes]
		   PACK_STRUCT_FIELD(u16_t proto);
		                           ^
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\src\ASF\thirdparty\lwip\lwip-port-1.4.1\sam\include\arch\cc.h(88,30): info: in definition of macro 'PACK_STRUCT_FIELD'
		 #define PACK_STRUCT_FIELD(x) x
		                              ^
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\src\ASF\thirdparty\lwip\lwip-1.4.1\src\include\netif\etharp.h(120,27): warning: packed attribute causes inefficient alignment for 'opcode' [-Wattributes]
		   PACK_STRUCT_FIELD(u16_t opcode);
		                           ^
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\src\ASF\thirdparty\lwip\lwip-port-1.4.1\sam\include\arch\cc.h(88,30): info: in definition of macro 'PACK_STRUCT_FIELD'
		 #define PACK_STRUCT_FIELD(x) x
		                              ^
		In file included from ../src/network/ethernet_sam.c:68:0:
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\src\ASF\thirdparty\lwip\lwip-1.4.1\src\include\netif\etharp.h(125,1): warning: packed attribute causes inefficient alignment for 'etharp_hdr' [-Wpacked]
		 } PACK_STRUCT_STRUCT;
		 ^
		Finished building: ../src/network/ethernet_sam.c
		Building target: DiTo_SAM4E_6.0_6_2(10).elf
		Invoking: ARM/GNU Linker : 4.9.3
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe" -o DiTo_SAM4E_6.0_6_2(10).elf  src/ASF/common/components/memory/sd_mmc/sd_mmc.o src/ASF/common/components/memory/sd_mmc/sd_mmc_mem.o src/ASF/common/services/sleepmgr/sam/sleepmgr.o src/ASF/common/services/spi/sam_spi/spi_master.o src/ASF/sam/components/ethernet_phy/ksz8051mnl/ethernet_phy.o src/ASF/sam/components/resistive_touch/ads7843/ads7843.o src/ASF/sam/drivers/gmac/gmac_phy.o src/ASF/sam/drivers/gmac/gmac_raw.o src/ASF/sam/drivers/spi/spi.o src/ASF/sam/drivers/tc/tc.o src/ASF/sam/services/resistive_touch/rtouch.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/api_lib.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/api_msg.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/err.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/netbuf.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/netdb.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/netifapi.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/sockets.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/api/tcpip.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/def.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/dhcp.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/dns.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/autoip.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/icmp.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/igmp.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/inet.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/inet_chksum.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/ip.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/ip_addr.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/ipv4/ip_frag.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/lwip_init.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/lwip_timers_141.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/mem.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/memp.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/netif.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/pbuf.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/raw.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/stats.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/sys.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/tcp.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/tcp_in.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/tcp_out.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/core/udp.o src/ASF/thirdparty/lwip/lwip-1.4.1/src/netif/etharp.o src/ASF/thirdparty/lwip/lwip-port-1.4.1/sam/netif/sam4e_gmac.o src/event_classify.o src/File_managment.o src/network/ethernet_sam.o src/network/ftpserver/ftpd.o src/network/ftpserver/vfs.o src/network/httpserver/cgi.o src/network/httpserver/fs.o src/network/httpserver/fsdata.o src/network/httpserver/httpd.o src/network/timer_mgt_sam.o src/ASF/sam/drivers/afec/afec.o src/ASF/sam/drivers/pio/pio_handler.o src/ASF/common/utils/stdio/read.o src/ASF/sam/drivers/hsmci/hsmci.o src/ASF/sam/drivers/pio/pio.o src/ASF/thirdparty/fatfs/fatfs-port-r0.09/diskio.o src/ASF/thirdparty/fatfs/fatfs-port-r0.09/sam/fattime_rtc.o src/ASF/thirdparty/fatfs/fatfs-r0.09/src/option/ccsbcs.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/FreeRTOS_CLI.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/list.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/portable/gcc/arm_cm4f/port.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/portable/memmang/heap_4.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/queue.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/tasks.o src/ASF/thirdparty/freertos/freertos-7.3.0/source/timers.o src/ASF/common/utils/stdio/write.o src/ASF/common/services/serial/usart_serial.o src/ASF/common/services/delay/sam/cycle_counter.o src/ASF/common/services/storage/ctrl_access/ctrl_access.o src/ASF/sam/components/display/aat31xx/aat31xx.o src/ASF/sam/drivers/ebi/smc/smc.o src/ASF/sam/drivers/pdc/pdc.o src/ASF/sam/drivers/rtc/rtc.o src/ASF/sam/drivers/uart/uart.o src/ASF/sam/drivers/usart/usart.o src/ASF/thirdparty/fatfs/fatfs-r0.09/src/ff.o src/ASF/sam/components/display/ili93xx/ili93xx.o src/ASF/common/services/clock/sam4e/sysclk.o src/ASF/common/utils/interrupt/interrupt_sam_nvic.o src/ASF/sam/boards/sam4e_ek/init.o src/ASF/sam/drivers/pmc/pmc.o src/ASF/sam/drivers/pmc/sleep.o src/ASF/sam/utils/cmsis/sam4e/source/templates/exceptions.o src/ASF/sam/utils/cmsis/sam4e/source/templates/gcc/startup_sam4e.o src/ASF/sam/utils/cmsis/sam4e/source/templates/system_sam4e.o src/ASF/sam/utils/syscalls/gcc/syscalls.o src/diagnostics_loop.o src/events_logging.o src/main.o   -mthumb -Wl,-Map="DiTo_SAM4E_6.0_6_2(10).map" -Wl,--start-group -larm_cortexM4lf_math -lm  -Wl,--end-group -L"../cmsis/linkerScripts" -L"../src/ASF/thirdparty/CMSIS/Lib/GCC"  -Wl,--gc-sections -mcpu=cortex-m4 -Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e16/gcc/flash.ld  
c:/program files (x86)/atmel/studio/7.0/toolchain/arm/arm-gnu-toolchain/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe(0,0): warning: size of symbol `context_code' changed from 64 in src/event_classify.o to 19 in src/diagnostics_loop.o
		src/network/ftpserver/ftpd.o: In function `cmd_cwd':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(746,1): error: undefined reference to `f_chdir'
		src/network/ftpserver/ftpd.o: In function `cmd_cdup':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(755,1): error: undefined reference to `f_chdir'
		src/network/ftpserver/ftpd.o: In function `ftpd_msgaccept':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(1349,1): error: undefined reference to `vfs_openfs'
		src/network/ftpserver/ftpd.o: In function `send_next_directory':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(539,1): error: undefined reference to `vfs_stat'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(539,1): error: undefined reference to `vfs_closedir'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(539,1): error: undefined reference to `vfs_readdir'
		src/network/ftpserver/ftpd.o: In function `send_file':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(473,1): error: undefined reference to `vfs_read'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(473,1): error: undefined reference to `vfs_close'
		src/network/ftpserver/ftpd.o: In function `ftpd_msgerr':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(1186,1): error: undefined reference to `vfs_close'
		src/network/ftpserver/ftpd.o: In function `ftpd_msgsent':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(1220,1): error: undefined reference to `vfs_close'
		src/network/ftpserver/ftpd.o: In function `cmd_dele':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(1080,1): error: undefined reference to `vfs_stat'
		src/network/ftpserver/ftpd.o: In function `cmd_rmd':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(1053,1): error: undefined reference to `vfs_stat'
		src/network/ftpserver/ftpd.o: In function `cmd_stor':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(856,1): error: undefined reference to `vfs_open'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(856,1): error: undefined reference to `vfs_close'
		src/network/ftpserver/ftpd.o: In function `cmd_retr':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(836,1): error: undefined reference to `vfs_stat'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(836,1): error: undefined reference to `vfs_open'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(836,1): error: undefined reference to `vfs_close'
		src/network/ftpserver/ftpd.o: In function `ftpd_datarecv':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(601,1): error: undefined reference to `vfs_write'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(601,1): error: undefined reference to `vfs_close'
		src/network/ftpserver/ftpd.o: In function `cmd_pwd':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(765,1): error: undefined reference to `vfs_getcwd'
		src/network/ftpserver/ftpd.o: In function `cmd_list_common':
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(798,1): error: undefined reference to `vfs_getcwd'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(798,1): error: undefined reference to `vfs_opendir'
C:\Users\imolaahm\Documents\Working Folder\SAM4E_Ismet\FTP\FTP\DiTo_SAM4E_7.3_1-(doanloading file 12kB) - Copy - Copy\DiTo_SAM4E_6.0\Debug/../src/network/ftpserver/ftpd.c(798,1): error: undefined reference to `vfs_closedir'
collect2.exe(0,0): error: ld returned 1 exit status
		make: *** [DiTo_SAM4E_6.0_6_2(10).elf] Error 1
		The command exited with code 2.
	Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "DiTo_SAM4E_6.0_6_2(10).cproj" -- FAILED.
Done building project "DiTo_SAM4E_6.0_6_2(10).cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Since I'm using a httpserver already I'm not sure if including a ftpserver will be an issue. I'm trying to include https://github.com/toelke/lwip-ftpd the ftpserver from here. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well "undef ref" just means "no C file contained this function". Looking at the actual errors some of those function names look like FatFS functions - so is it involved in this code? If so then those functions usually live in a source file called ff.c. So is that present? If so why has it not been added to the project as one of the files to be built?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, you are right the FatFs is included in the project, And I have included it in vfs.c and vfc.h, but still the problem still same error!!

 

#ifndef INCLUDE_VFS_H
#define INCLUDE_VFS_H
//#include <sys/time.h>
#include <ff.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

#define time(x)
#define vfs_eof f_eof
#define VFS_ISDIR(st_mode) ((st_mode) & AM_DIR)
#define VFS_ISREG(st_mode) !((st_mode) & AM_DIR)
#define vfs_rename(vfs, from, to) f_rename(from, to)
#define VFS_IRWXU 0
#define VFS_IRWXG 0
#define VFS_IRWXO 0
#define vfs_mkdir(vfs, name, mode) f_mkdir(name)
#define vfs_rmdir(vfs, name) f_unlink(name)
#define vfs_remove(vfs, name) f_unlink(name)
#define vfs_chdir(vfs, dir) f_chdir(dir)
char* vfs_getcwd(vfs_t* vfs, void*, int dummy);
int vfs_read (void* buffer, int dummy, int len, vfs_file_t* file);
int vfs_write (void* buffer, int dummy, int len, vfs_file_t* file);
vfs_dirent_t* vfs_readdir(vfs_dir_t* dir);
vfs_file_t* vfs_open(vfs_t* vfs, const char* filename, const char* mode);
vfs_t* vfs_openfs();
void vfs_close(vfs_t* vfs);
int vfs_stat(vfs_t* vfs, const char* filename, vfs_stat_t* st);
void vfs_closedir(vfs_dir_t* dir);
vfs_dir_t* vfs_opendir(vfs_t* vfs, const char* path);
struct tm* gmtime(time_tr *c_t);
#endif /* INCLUDE_VFS_H */

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was thinking more of f_chdir which is a function usually in ff.c not vfs.c

 

To be honest I don't know what vfs.c even is - does that come with FatFS ?

 

Anyway if you think vfs.c is in the build in all your build output do you actually see an invocation of gcc -c using vfs.c as the input file? If you do I can only assume it contains #if/#ifdef that are predicated on some symbol that is not defined. For that one use -save-temps and look at vfs.i that is generated after pre-processing.

 

Another option is that it's really vfs.cpp (that is C++ code) and the link names are in a namespace or mangled.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

https://github.com/toelke/lwip-f... This is the FTP server that I'm trying to implement, but to be honest haha I'm not really sure if that is c++ if it's I"m feeling really dump at the moment!! :D

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Makefile is notable by its absence there! So how do you know how to build these file?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well good question, I have an already build a HTTP stack using a lwip and FreeRTOS so I'm following that approach, cuz they are similar.  But anyway, I think I'll simpy use the function directly from ff.h instead  vsf.h 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So is this a SAM question? If so why have you posted it in the AVR forum? smiley

 

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Fri. Jun 17, 2016 - 10:36 PM