Question

I want to use libgadu (library of instant messaging protocol) under Visual Studio 2008. I have downloaded libgadu http://toxygen.net/libgadu/files/libgadu-1.8.2.tar.gz and under cygwin I've compiled it - ./configure , make , make install. File libgadu.h which appeard in include folder I copied to another folder which is marked in VS as Including files directory.

I wanted to compile code from documentation

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <libgadu.h>

using namespace std;

int main(void)
{
    char password[]= "haslo";
    struct gg_session *sesja;
    struct gg_login_params parametry;
    struct gg_event *zdarzenie;

    memset(&parametry, 0, sizeof(parametry));
    parametry.uin = 12345;
    parametry.password = password;
    parametry.async = 1;
    parametry.status = GG_STATUS_INVISIBLE;


    sesja = gg_login(&parametry);
    if (!sesja) {
        cout << "Can't connect" << endl;
       exit(1);
    }

    system("PAUSE");
}

During compiling i receive two errors:

Error   1   error LNK2019: unresolved external symbol _gg_login referenced in function _main    1.obj
Error   2   fatal error LNK1120: 1 unresolved externals 

What should I do with it?

Was it helpful?

Solution

You need to locate the compiled DLL and LIB file, or just LIB file if it was compiled into a static library. The files will probably be named libgadu.dll and libgadu.lib.

Once you have those, you can instruct Visual Studio to link with the LIB file by selecting Project Properties and locating the Additional Dependencies under the Linker settings.

Just add libgadu to the additional dependencies list for All Configurations.

OTHER TIPS

As Frank has already said, this usually means a library (.lib or .dll) is not getting linked against. However, if a successful compile doesn't create .dll or .lib files, then the most likely case is that the build systems between Cygwin and VS are out of sync.

Specifically, a file is not getting referenced in the VS project file. I have a feeling it is libgagdu.c itself as there is a gg_login function defined in it.

Just add that file to the project and rebuild. If it works, contact the libgadu developers so they can fix it on their end.

It's strange, because during ./configure, make in Cygwin, it doesn't create any .dll and .lib files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top