Thomas Hruska wrote: > Stephane Lesoinne wrote: >> Hi, >> >> I've a C program that compile with g++ and I'm trying to have it >> compiled by Micorosoft Visual C++ Express 2008. >> The problem is that at the link stage, I've error lnk2019 and lnk2001 >> occurring for functions defined in the source code. >> >> Here are the errors : >> >> 1>cinaudio.obj : error LNK2019: symbole externe non résolu "int __cdecl >> copyPoint(struct point_t *,struct point_t *)" >> (?copyPoint@@YAHPAUpoint_t@@[EMAIL PROTECTED]) référencé dans la fonction >> "int __cdecl >> moveSource(int,struct point_t *,struct auralizationInfo_t *)" >> (?moveSource@@YAHHPAUpoint_t@@PAUauralizationInfo_t@@@Z) > <snip> > >> 1>F:\Mes Documents\Visual Studio >> 2008\Projects\AuraWinLionel\Debug\AuraWinLionel.exe : fatal error >> LNK1120: 11 externes non résolus >> >> >> Sorry, the text is in french but "symbole externe non résolu" means >> "external symbol not found" >> >> The functions prototype are given in "geometry.h" and the definitions >> are in "geometry.c". >> >> I'll use the first error as an example. >> >> Part of geometry.h : >> >> /extern int convertSphToCart2(SphVec *from, CartVec *to); >> extern int convertSphToCart(SphVec *from, CartVec *to); >> extern int convertCartToSph(CartVec *from, SphVec *to); > <snip> >> Part of geometry.c : > <snip> > >> All these files are included in one project and the compiler is the >> standard micorsoft C++ compiler delivered with MSVC++ 2008. >> I can't figure where the errors come from. >> >> Any ideas ? > > Yup. You are probably building a .cpp file and using the header > geometry.h in that .cpp file. The compiler is looking for name-mangled > names. You need to use extern "C" with some #ifdef logic or rename > geometry.c to geometry.cpp.
Clarification: The linker is looking for the name-mangled names the C++ compiler generated in the object file based on the input header file. The linker will find both mangled names (.cpp) and non-mangled names (.c) in the object files but won't be able to make the necessary association as it treats them as two different function calls. Hence the error messages. I just figured it would be simpler to say "The compiler is looking for..." instead of authoring a whole new paragraph about how the compiler and linker work. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
