Its a linker problem, the linker is unable to locate the g2 functions. This is simply because you never told the linker what libraries to link to. I dont know what the g2 library is called, if you look in the library directories and see something like libg2.so or whatever, just cut off the first part, the "lib", and then you have the library name to link to, as so:
assuming the actual library file is called "libg2.whatever"
the "-l" switch tells the compiler what libraries to link against, immediately following that switch, without a space, is the library name.