|
|
Re: Eclipse Mixing C and C++ [message #1720263 is a reply to message #1720182] |
Fri, 15 January 2016 15:44 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
Did you surround the prototypes for the C code such as below?
// link to a C function
extern "C" {
void PrintHello();
}
If you don't, the linker will be looking for a mangled name despite reporting an error using the unmangled one.
EDIT:
I removed the extraneous ';' after the extern statement.
To further comment, here's the linker output without the extern "C":
Invoking: GCC C++ Linker
g++ -o "GSL_TEST" ./src/GSL_TEST.o ./src/PrintHello.o -lgsl -lgslcblas -lm
./src/GSL_TEST.o: In function `main':
/home/dvavra/workspaces/workspace/GSL_TEST/Debug/../src/GSL_TEST.cpp:22: undefined reference to `PrintHello()'
collect2: error: ld returned 1 exit status
Note that PrintHello.o is being linked but the linker says it can't find PrintHello() despite it being contained in PrintHello.c. Is this similar to what you are seeing?
[Updated on: Fri, 15 January 2016 16:00] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03234 seconds