Hello everyone,
I have been searching the forums trying to find a solution to this but I have come up empty. There are plenty of posts regarding this error, but none (that I can find) in reference to switching to C++.
I have created a (rather large) code base that I have successfully implemented in C. It compiles and runs just fine. However, I would like to simplify some of the coding by making use of some of C++'s awesome features.
When I try to convert to C++, it no longer compiles and I get a lot of linker errors. I have set the compiler directive to --cpp and have renamed all of the files to .cpp (instead of .c).
I am using the TCP, and RTX libraries (if you cant tell from the errors).
The following is the output of the linker:
linking... .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_EnAuth (referred from http_cgi.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_NumSocks (referred from http_cgi.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol __debug__ (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol __error__ (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_2MSSTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_ConRetry (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_InitRetryTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_MaxRetry (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_RetryTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_SynRetryTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol udp_NumSocks (referred from at_udp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol MPool_Size (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_NumSess (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_PortNum (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_auth_dev (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_auth_user (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_DefTout (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol dns_TabSize (referred from at_dns.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol netif_cfg (referred from at_dns.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tick_rate (referred from at_dns.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol init_debug (referred from at_system.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol nlocalm (referred from at_system.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol mp_stk_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol mp_tcb_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol mp_tmr_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_error (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_fifo_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_idle_demon (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_maxtaskrun (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_stackinfo (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_trv (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_flags (referred from hal_cm3.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_MaxRetry (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_Resend (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_TabSize (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_TimeOut (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_rrobin (referred from rt_robin.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol igmp_T200ms (referred from at_igmp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol igmp_TabSize (referred from at_igmp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol igmp_table (referred from at_igmp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_tmr_call (referred from rt_timer.o). .\Obj\SPARQ.axf: Not enough information to list image symbols. .\Obj\SPARQ.axf: Not enough information to list the image map. .\Obj\SPARQ.axf: Finished: 2 information, 0 warning and 41 error messages.
I know it is just something really stupid but I just cant figure it out. I would greatly appreciate any help/advice that you can give.
Oh, in case it matters, I am using the MCB1700 demo board with the LPC1768 chip.
Thanks in advance,
Jon
If it doesn't compile, then Linker errors are to be expected!
You'll need to get it compiling first...
Also, do "the TCP, and RTX libraries" expect to be linking to C or C++ object files?
If the libraries are expecting to link to C object files, then you'll have to specify that in your C++ sources with :
extern "C" { // C prototypes }
developers.sun.com/.../mixing.html
Thanks for the VERY quick reply.
I believe that it compiles (forgive me, I am somewhat new to this). Here is the complete output:
Build target 'SPARQ' assembling startup_LPC17xx.s... compiling main.cpp... compiling HTTP_CGI.cpp... compiling File_Config.cpp... File_Config.cpp(134): warning: #177-D: variable "_CPU_CLK" was declared but never referenced File_Config.cpp: U32 const _CPU_CLK = CPU_CLK; File_Config.cpp: ^ File_Config.cpp(153): warning: #177-D: variable "_BASE_ADR" was declared but never referenced File_Config.cpp: U32 const _BASE_ADR = FL_BADR; File_Config.cpp: ^ File_Config.cpp: File_Config.cpp: 2 warnings, 0 errors compiling Net_Config.cpp... compiling Net_Debug.cpp... compiling RTX_Conf_CM.cpp... custom translating Web.inp... Custom: C:\Keil\ARM\bin\fcarm @Web\Web.inp FCARM FILE CONVERTER V2.26 Completed 12 File(s), Ratio 97% compiling Web.c... Web\Web.c(15): warning: #177-D: variable "FileMD" was declared but never referenced Web\Web.c: const U32 FileMD = 1291051176; Web\Web.c: ^ Web\Web.c(3804): warning: #177-D: variable "FileTab" was declared but never referenced Web\Web.c: const HTTP_FILE FileTab[13] = { Web\Web.c: ^ Web\Web.c: Web\Web.c: 2 warnings, 0 errors compiling SPI_LPC17xx.cpp... compiling EMAC_LPC17xx.cpp... compiling GLCD_SPI_LPC1700.cpp... compiling system_LPC17xx.cpp... linking... .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_EnAuth (referred from http_cgi.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_NumSocks (referred from http_cgi.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol __debug__ (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol __error__ (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_2MSSTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_ConRetry (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_InitRetryTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_MaxRetry (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_RetryTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_SynRetryTout (referred from at_tcp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol udp_NumSocks (referred from at_udp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol MPool_Size (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_NumSess (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_PortNum (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_auth_dev (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol http_auth_user (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tcp_DefTout (referred from at_http.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol dns_TabSize (referred from at_dns.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol netif_cfg (referred from at_dns.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol tick_rate (referred from at_dns.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol init_debug (referred from at_system.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol nlocalm (referred from at_system.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol mp_stk_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol mp_tcb_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol mp_tmr_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_error (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_fifo_size (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_idle_demon (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_maxtaskrun (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_stackinfo (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_trv (referred from rt_task.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_flags (referred from hal_cm3.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_MaxRetry (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_Resend (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_TabSize (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol arp_TimeOut (referred from at_arp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_rrobin (referred from rt_robin.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol igmp_T200ms (referred from at_igmp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol igmp_TabSize (referred from at_igmp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol igmp_table (referred from at_igmp.o). .\Obj\SPARQ.axf: Error: L6218E: Undefined symbol os_tmr_call (referred from rt_timer.o). .\Obj\SPARQ.axf: Not enough information to list image symbols. .\Obj\SPARQ.axf: Not enough information to list the image map. .\Obj\SPARQ.axf: Finished: 2 information, 0 warning and 41 error messages. Target not created
As far as I can tell, a lot of these errors come from the RTX_CM3.lib and TCP_CM3.lib files. Maybe they aren't compiling? They are included in my project, but I don't see any reference to them in the above output.
I think you are pointing me in the right direction - they are most likely designed for C. I am still not quite sure, even after reading the link you posted (thanks for that), how to make the libraries work with my code.
It was my understanding that the Keil libraries were C++ compatible and that I shouldn't have to change their libraries to make it work. The only two that I have control over are the ones in HTTP_CGI.o and those are referencing variables defined in NET_CONFIG (A Keil library file).
It sounds like you have alot of experience in this area, perhaps you can give me another quick hint to get me going in the right direction.
Thanks!
Sorry for the double post, I tried:
extern "C" U8 const tcp_NumSocks; extern "C" U8 const http_EnAuth;
and it still gives the same error.
Have you made sure that _every_ c++ source file that makes use of tcp_NumSocks or http_EnAuth are guaranteed to see the extern "C" declaration?
Easiest is to do:
extern "C" { #include <xxx> #include <yyy> }
for all header files you don't know if they are C++ compliant. But for situations where you have a variable in your code that a C library links to, then you need to make sure that your symbol also uses the C naming convention and not the C++ naming convention.
The troubles when mixing C and C++ is that C++ added type-safe linking by having the compiler add extra characters to all symbol names, to encode data types. And the C++ compiler must be informed which symbols that may not add this mangling, i.e. that may not perform type-safe linking.
Thanks again for your awesome reply. I will take a very close look and report back.
It worked, thanks.
Surrounding the header calls in the extern "C" worked great.
Thanks for your help.