R
R
Robotex2011-03-22 03:12:15
Qt
Robotex, 2011-03-22 03:12:15

Qt4: a function defined in one file is not visible in another?

Here is the project ubuntuone.com/p/hiv/ (you need libfprint-dev for compilation)
When building, an error message pops up:

/home/robotex/workspace/qt_fprint-build-desktop/cfingerprintscanner.o:: In function `CFingerprintScanner::comparePrintData(CFingerprintData, CFingerprintData)':<br/>
/home/robotex/workspace/qt_fprint-build-desktop/../qt_fprint/cfingerprintscanner.cpp:475: error: undefined reference to `bozorth_main(xyt_struct*, xyt_struct*)'<br/>
:: error: collect2: ld returned 1 exit status<br/>

specifically at this stage:
g++ -o qt_fprint main.o mainwindow.o cfingerprintscanner.o cfingerprintdata.o bz_sort.o bz_io.o bz_gbls.o bz_drvrs.o bz_alloc.o bozorth3.o moc_mainwindow.o moc_cfingerprintscanner.o -L/usr/lib -lfprint -lQtGui -lQtCore -lpthread <br/>
cfingerprintscanner.o: In function `CFingerprintScanner::comparePrintData(CFingerprintData, CFingerprintData)':<br/>
/home/robotex/workspace/qt_fprint-build-desktop/../qt_fprint/cfingerprintscanner.cpp:475: undefined reference to `bozorth_main(xyt_struct*, xyt_struct*)'<br/>
collect2: ld returned 1 exit status<br/>
make: *** [qt_fprint] Помилка 1<br/>

Although the function exists in the bz_drvrs.c file Header files are also included
What is the problem? Where did I screw up?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
shurshur, 2011-03-22
@Robotex

Your bz_drvrs.c is written in C, and the project itself is written in C++. To call C functions from C++ code, you must use extern "C", since the formation of internal names in .o files differs for these languages.
To make portable code, you usually do something like this: As a result, the .h file works fine in both C and C++.
#ifdef __cplusplus
extern "C" {
#endif
// основное содержимое .h-файла
#ifdef __cplusplus
} // extern "C"
#endif

Y
YourChief, 2011-03-22
@YourChief

let's make a makefile or a script that you collect, I'll try to compile it myself

E
Eol, 2011-03-22
@Eol

You are using the external dynamic library Libfprint. You need to tell the linker to link with it. To do this, in the .pro file of your Qt project (if you use QMake / Qt-Creator) you need to add the line
LIBS += -lfprint
I can be wrong with “fprint” - I don’t know the specific name, but the essence is the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question