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
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.