Windows下编译libgadu

发布于 2024-07-10 01:33:12 字数 1212 浏览 8 评论 0原文

我想在Visual Studio 2008下使用libgadu(即时通讯协议库)。 我已经下载了 libgadu http://toxygen.net/libgadu/files/ libgadu-1.8.2.tar.gz 并在 cygwin 下编译它 - ./configure 、 make 、 make install 。 文件 libgadu.h 出现在包含文件夹中,我将其复制到另一个文件夹,该文件夹在 VS 中标记为包含文件目录。

我想从文档编译代码

#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");
}

在编译过程中,我收到两个错误:

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

我应该用它做什么?

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(¶metry, 0, sizeof(parametry));
    parametry.uin = 12345;
    parametry.password = password;
    parametry.async = 1;
    parametry.status = GG_STATUS_INVISIBLE;


    sesja = gg_login(¶metry);
    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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吃兔兔 2024-07-17 01:33:13

正如弗兰克已经说过的,这通常意味着库(.lib 或 .dll)没有被链接。 但是,如果成功编译没有创建 .dll 或 .lib 文件,那么最可能的情况是 Cygwin 和 VS 之间的构建系统不同步。

具体来说,VS 项目文件中未引用文件。 我有一种感觉,它是 libgagdu.c 本身,因为在中定义了一个 gg_login 函数它。

只需将该文件添加到项目中并重建即可。 如果它有效,请联系 libgadu 开发人员,以便他们可以修复它。

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.

雨后彩虹 2024-07-17 01:33:13

您需要找到已编译的 DLL 和 LIB 文件,或者如果编译成静态库,则只需找到 LIB 文件。 这些文件可能被命名为 libgadu.dll 和 libgadu.lib。

获得这些后,您可以通过选择“项目属性”并在“链接器设置”下找到“附加依赖项”来指示 Visual Studio 与 LIB 文件链接。

只需将 libgadu 添加到所有配置的附加依赖项列表中即可。

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.

青萝楚歌 2024-07-17 01:33:13

这很奇怪,因为在 ./configure、Cygwin 中 make 期间,它不会创建任何 .dll 和 .lib 文件。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文