PDA

View Full Version : Need help accessing AVT camera (with wrapper?)!



emigrand
4th April 2012, 11:07
Hello, I urgently need your help!

I'm trying to involve an AVT Pike camera into my Qt project. When I add the libraries to my .pro-file and instantiate a CFGCamera object (gives access to camera functionalities), the programm fails link(?) and gives me following errors:

:: error: undefined reference to '_imp__ZN9CFGCameraD1Ev'
:: error: undefined reference to '_imp__ZN9CFGCameraD1Ev'
:: error: undefined reference to '_imp__ZN9CFGCameraD1Ev'
:: error: collect2: ld returned 1 exit status

Since I use the MinGW compiler, I think that the following thread in AVT's Knowledge Base is the solution to my problems:


FireGrab with Dev C++ and MinGW/GCC compiler

The CFGCamera object of the MS VS C++ library FGCamera.lib could not be converted to MinGW compatible *.a library. That's why there's the C-wrapper FGWrap.dll providing the functions of the FireGrab interface to a camera handle instead of an CFGCamera object.

The FireGrab\Lib\Extra\FGWrap.lib could be loaded to your Dev C++ project easily as shown at the modified WrapSample.
FGCamera.lib has to be included just to initialize the module and get the nodelist.


But even with this approach I cannot access the camera. Can somebody tell me what I am doing wrong? My .pro-file now looks like this:

INCLUDEPATH += C:/FirePackage/FireGrab/Lib/Extra
LIBS += C:/FirePackage/FireGrab/Lib/Extra/FGWrap.lib
LIBS += C:/FirePackage/FireGrab/Lib/FGCamera.lib
The Lib folder contains following files:

FGCamara.dll
convert.c
basetype.h
convert.h
errstat.h
FGCamera.h
FGCamera.lib
FGCamera_omf.lib


The Extra folder contains following files:

FGWrap.dll
Camera.h
FGWrap.h
IsoDma.h
FGWrap.cpp
FGWrap.lib
FGWrap_omf.lib


My main.cpp:


#include <fgcamera.h>
#include <fgwrap.h>

int main(int argc, char *arbv[])
{
QApplication a(argc, argv);
FGHandle hCamera; //this is the substitute for the CFGCamera object
FGNODEINFO NodeInfo[3];
UINT32 NodeCnt;

FGInitModule(NULL);
FGGetNodeList(NodeInfo,3,&NodeCnt);

hCamera = NULL;
FGGetCameraHandle(&hCamera,&NodeInfo[0].Guid,NULL); //here it exits
...
return a.exec();
}
When I execute it, it exits at the mentioned line with a return value -1073741515. Since this is adapted from a sample I am pretty sure that the parameters etc. are fine. I could access the camera with MSVS2010 Express as well, no problem.

So how do I use the wrapper? Maybe someone could test it on his system, the library can be downloaded here (http://www.alliedvisiontec.com/fileadmin/content/PDF/Software/AVT_software/zip_files/AVTFirePackage_3v0.zip).
Another possibility might be to generate a MinGW compatible library from FGCamera.dll with pexports(!?), but I don't know how to do that and if it's feasible, because AVT says it is not (see above).

Last to mention my setup:
Qt 4.7.0
Qt Creator 2.0.1
MinGW-Compiler
Windows 7

Sorry for cross-posting(?), but initially I picked up an old thread in the Qt-programming forum. I didn't want to bother them with newbie questions anymore.

Thanks for your assistance.

ChrisW67
4th April 2012, 22:18
The *.lib files will not work directly with MingW (the second paragraph is about Dev C++). You should find the MingW linker will work directly against the C wrapper DLL. Try this:


INCLUDEPATH += C:/FirePackage/FireGrab/Lib/Extra
LIBS += -LC:/FirePackage/FireGrab/Lib/Extra -lFGWrap

emigrand
8th April 2012, 10:17
Thanks a lot Chris, that did it! Although I didn`t "fully" understand the magic behind your code. A short comment would be nice:)

ChrisW67
9th April 2012, 00:50
INCLUDEPATH is used during the compilation of your C++ code into object files (*.obj or *.o). Any #include "file.h" directive will potentially search through directories listed in INCLUDEPATH in order to find "file.h" if it is not in the current directory.

LIBS controls the linking phase, where your object files are coalesced into your target executable or library. The "-L" entries specify a directory to search for named libraries (there can be several). The "-l" (lower case L) entries specify the name of libraries (*.lib or *.a) to search for routines used by your program that are not present in your program.

C++ compilers do not generally create libraries compatible with other C++ compilers for technical reasons: which is why the C++ interface library built with MSVC is not available to you using MingW. A C-style interface is portable between compilers but, for obvious reasons, cannot export classes or other C++ constructs. The C-style interface gives you a handle-based interface in your wrapper. MingW can often use a DLL with C-style interfaces directly without a separate *.lib or *.a file: this is what has worked here.