Answer the question
In order to leave comments, you need to log in
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/>
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/>
Answer the question
In order to leave comments, you need to log in
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
let's make a makefile or a script that you collect, I'll try to compile it myself
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 questionAsk a Question
731 491 924 answers to any question