Hi,
I'm trying to link c object with c++ (using QT Library) object and find the following error.
tonysun:~/tmp# g++ -c main.cpp
tonysun:~/tmp# gcc -c mainlib.c
tonysun:~/tmp# g++ -o main main.o mainlib.o main.cpp:(.text+0x64): undefined reference to `para_prep()'
<<main.cpp>>
#include "mainlib.h"
int main(int argc, char *argv[])
{
para_prep();
/* Here are code that using QT/C++ library
*/
return 0;
}
<mainlib.c>
#include "inc.h"
void para_prep()
{
/* Here are code that using C library only
*/
}
<<mainlib.h>>
void para_prep();
If I remove the QT/C++ code in main.cpp
and change main.cpp
to main.c
and g++ -c main.cpp
to gcc -c main.cpp
, it will be fine.
How can I link them?
Any suggestion will be appreciated.