views:

364

answers:

4

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?

+2  A: 

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.

Frank Krueger
A: 

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

mich
The symbol may be in a .o (or .obj) file as the result of compiling a .c file.
Max Lybbert
+1  A: 

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.

Max Lybbert
A: 

After adding libgadu.c I had to add whole etc/usr/include folder to VS Include files. However there are some errors during compiling, but not directly in my program but in those include files comming from cygwin ;/

"The symbol may be in a .o (or .obj) file as the result of compiling a .c file."

After ./configure make in src folder appear:

libgadu.la      1 KB   
libgadu_la-common.lo    1 KB  
libgadu_la-common.o     49 KB  
libgadu_la-dcc.lo   1 KB  
libgadu_la-dcc.o    73 KB  
libgadu_la-dcc7.lo  1 KB  
libgadu_la-dcc7.o   66 KB  
libgadu_la-events.lo    1 KB  
libgadu_la-events.o     82 KB  
libgadu_la-http.lo  1 KB  
libgadu_la-http.o   50 KB  
libgadu_la-libgadu.lo   1 KB  
libgadu_la-libgadu.o    74 KB  
libgadu_la-obsolete.lo  1 KB  
libgadu_la-obsolete.o   37 KB  
libgadu_la-pubdir.lo    1 KB  
libgadu_la-pubdir.o     47 KB  
libgadu_la-pubdir50.lo  1 KB  
libgadu_la-pubdir50.o   41 KB  
libgadu_la-sha1.lo  1 KB  
libgadu_la-sha1.o 39 KB

But content of .o files looks like that:

    L     ¤ X     .text           Ŕ(    č     $    P`.data                               @ 0Ŕ.bss            0                   € 0Ŕ.stab           ¤O  Ä)  P     "     0.stabstr        !‹  hy                .rdata          \
  ‰             @ 0@U¸    ‰ĺ]ĂŤ¶    U‰ĺ‹E]ÐŤ´&    U‰ĺ·E]ĂŤ´&    U‰ĺ‹UV‹uS1Űë'ă ˙˙˙¶Ŕ Ă1ÚFÚÁă1ÚÁă)ÚÁă1ډуáÓ¶„ŔuÓ[‰Đ^]ĂŤ¶    ŤĽ'    Uş   ‰ĺƒě8‹E‰uř‹u‰}ü‹}‰D$‰T$‰]ô‰|$‰t$Ç$   č    …ö”Ŕ…˙” ШuFŤEč‰$č    @ş˙˙˙˙t$č    ƒř˙‰Ăt|…Ŕt5‹Eě‰$č    ‹Eč1Ň

I've to find another way...

mich