undefined reference to ...

B

benzasu

Hi i am trying to compile a set of programs but i receive the following
error with try to make the time running program, i write my program in
C and try to call a C++ function of a library building in and
compilated succesfully in C++,

the funtion (in C++) is:
#include "header.h"
.....
extern "C" int llamada(int det,pgmd* ventana) { ... }
......

with a header :
#ifdef __cplusplus
extern "C"
#endif
int llamada(int det, pgmd* ventana);

and the calling in C is:
#include "header.h"
.....
det = llamada(ii, &ventana);
.....

The result of compilation is:

server@user:~/Gideo-0TRY/src$ gcc -Wall -g -lcrypt -o gideo support.o
main.o interface.o callbacks.o avilib.o spcadecoder.o spcav4l.o utils.o
-Wl,--export-dynamic -L/usr/local/lib -L/usr/X11R6/lib
/usr/lib/libgnomeui-2.so -L/usr/lib /usr/lib/libgnome-keyring.so
/usr/lib/libbonoboui-2.so -lSM -lICE /usr/lib/libgnomecanvas-2.so
/usr/lib/libgtk-x11-2.0.so /usr/lib/libgdk-x11-2.0.so
/usr/lib/libgdk_pixbuf-2.0.so /usr/lib/libgnome-2.so /usr/lib/libesd.so
/usr/lib/libaudiofile.so /usr/lib/libart_lgpl_2.so
/usr/lib/libpangoft2-1.0.so /usr/lib/libgnomevfs-2.so
/usr/lib/libxml2.so /usr/lib/libgnutls.so /usr/lib/libtasn1.so
/usr/lib/libgcrypt.so -lnsl /usr/lib/libgpg-error.so -lresolv -lrt
/usr/lib/libbonobo-2.so /usr/lib/libgconf-2.so
/usr/lib/libbonobo-activation.so /usr/lib/libORBitCosNaming-2.so
/usr/lib/libORBit-2.so /usr/lib/libpopt.so /usr/lib/libgthread-2.0.so
/usr/local/lib/libgtk-x11-2.0.so /usr/local/lib/libgdk-x11-2.0.so
/usr/lib/libatk-1.0.so /usr/local/lib/libgdk_pixbuf-2.0.so
/usr/lib/libpangoxft-1.0.so /usr/lib/libpangox-1.0.so
/usr/lib/libpango-1.0.so /usr/lib/libgobject-2.0.so
/usr/lib/libgmodule-2.0.so /usr/lib/libglib-2.0.so -laudio -lXt -lX11
-lXext /usr/lib/libaa.so -lncurses -lslang /usr/lib/libasound.so -ldl
-lm /usr/lib/libSDL_image.so -ltiff /usr/lib/libjpeg.so -lpng -lz
/usr/lib/libSDL.so -lpthread -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath
-Wl,/usr/local/lib
/usr/bin/ld: warning: libtiff.so.4, needed by /usr/lib/libSDL_image.so,
may conflict with libtiff.so.3
main.o(.text+0x1660): In function `processvideo':
/home/user/Gideo-0TRY/src/main.c:640: undefined reference to `llamada'
collect2: ld returned 1 exit status

Thank you for your colaboration

benzasu
 
J

Jack Klein

Hi i am trying to compile a set of programs but i receive the following
error with try to make the time running program, i write my program in
C and try to call a C++ function of a library building in and
compilated succesfully in C++,

Pretty much anything to do with C++ is off-topic in this group. C,
which came first, does not define an interface to any other language,
and that includes C++. So this is not a C language issue.

Even if your C and C++ compilers provide a method of doing this, it is
100% compiler specific. Undefined references are generated by the
linker, and neither language defines the operation of such tools.

I would suggest you ask this question in
 
I

Ian Collins

benzasu said:
Hi i am trying to compile a set of programs but i receive the following
error with try to make the time running program, i write my program in
C and try to call a C++ function of a library building in and
compilated succesfully in C++,

the funtion (in C++) is:
#include "header.h"
.....
extern "C" int llamada(int det,pgmd* ventana) { ... }
......

with a header :
#ifdef __cplusplus
extern "C"
#endif
int llamada(int det, pgmd* ventana);
You probably want

#ifdef __cplusplus
extern "C" {
#endif

int llamada(int det, pgmd* ventana);

#ifdef __cplusplus
}
#endif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top