Problem using GenTL.h: Can't find the corresponding library in GenIcam Package

1.7k Views Asked by At

I'm working on a C++ console application that allows communication with GenICam compliant industrial cameras. I installed the latest GenICam package and integrated it in my project. First I got the error message C1083: Cannot open "GenTL.h", so I moved this header to the include folder and realized, that there is no corresponding binary. Now I get the following error message:

LNK2001 Unresolved external symboll "__imp_GCInitLib".

I'm not sure how to fix it. I guess I need to integrate a further *.lib, but I can't find any in the package. Am I missing something?

Thanks for any help!

2

There are 2 best solutions below

0
On

GenICam, or rather the GenAPI only handles the enumeration, unification (between different vendors), presentation of the camera features implementing GenICam.

GenTL on the other hand abstracts the transport interface and provides a standardized set of functions to the user.

So, if you want to work with camera features (GenAPI), you first need to work with a transport layer implementation to scan for cameras and communicate with them.

Being part of a standard means that the transport layer (GenTL) at least exposes the functions listed in GenTL.h but usually a lot more. Moreover, GenTL providers are - as you correctly stated - usually shared libraries which are provided by the manufacturer, usually suffixed with .cti.

Those can be dynamically loaded and the functions then used. Here is an example using a Basler GenTL provider:

#include <GenTL.h>
#include <dlfcn.h>
#include <dirent.h>


int main(){

    // Load DLL at runtime
    void *lib = dlopen("/opt/pylon/lib/pylonCXP/bin/ProducerCXP.cti", RTLD_NOW | RTLD_DEEPBIND);

    // Declare variables with variable definitions from GenTL.h
    GenTL::PGCInitLib GCInitLib;
    GenTL::PGCCloseLib GCCloseLib;

    // Dynamically bind GenTL functions to local function calls
    *reinterpret_cast<void**>(&GCInitLib) = dlsym(lib, "GCInitLib");
    *reinterpret_cast<void**>(&GCCloseLib) = dlsym(lib, "GCCloseLib");      

    GCInitLib(); // Init GenTL provider

    // [Discover cameras, open port, load GenICam, do things]

    GCCloseLib();
}

This can then be compiled with

g++ -l ldl main.cpp -o TestGenTL
0
On

.cti file is a dynamic load library. for windows, we can use functions from windows.h for loading the dll in runtime (LoadLibraryA, GetProcAddress).

HMODULE loadeddll = LoadLibraryA(filename.c_str());
PGCInitLib GCInitLib;
PGCCloseLib GCCloseLib;
PTLOpen TLOpen;
PTLClose TLClose;    
GCInitLib = (PGCInitLib)GetProcAddress(loadeddll, "GCInitLib");
GCCloseLib = (PGCCloseLib)GetProcAddress(loadeddll, "GCCloseLib");
TLOpen = (PTLOpen)GetProcAddress(loadeddll, "TLOpen");
TLClose = (PTLClose)GetProcAddress(loadeddll, "TLClose");