Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!rutgers!mcnc!uvaarpa!murdoch!hopper.cs.Virginia.EDU!fs8j From: fs8j@hopper.cs.Virginia.EDU (Fraser M. Street) Newsgroups: comp.lang.c++ Subject: Help! calling C++ functions from a C main program Message-ID: <1991Apr15.163426.14250@murdoch.acc.Virginia.EDU> Date: 15 Apr 91 16:34:26 GMT Sender: usenet@murdoch.acc.Virginia.EDU Reply-To: fs8j@hopper.cs.Virginia.EDU (Fraser M. Street) Organization: University of Virginia Lines: 23 Hi - I'm desperate for help. I have a C graphics application that, due to the nature of the source code, can only be compiled with a C compiler. I now need to use a relatively elaborate C++ class library to generate some data that will be used by my graphics code. All this code needs to be linked into one executable. I understand how to call a C function from a C++ main program (using "extern "C" foo();"), but I don't know how to make it work in the other direction - i.e. call my C++ foobar() function from my main.c file. I have tried separately compiling and linking the two .o files but the linker can't resolve the C++ function names. Is there a way for me to do this? Our environment is a network of SUN3 and SUN4 machines, all running Unix. The available compilers at this site are cc, CC, gcc, g++, and Saber C++. Please E-mail me any ideas. Thanks in advance. The project's due Friday!! Fraser