gsoap - 使用 -lcrypt 进行编译

发布于 2024-12-03 03:45:06 字数 683 浏览 0 评论 0原文

我在 ubuntu 下使用 C++ 代码工作。我正在使用 gsoap 来连接到服务器。我已经获得了所有必要的数据。我也成功连接到服务器了。我仍然有一个问题。为什么需要在命令行中写:g++ test_server.cpp -o testServ libgsoap++.a。如果我确实在文件夹中包含了所有依赖项,为什么需要在命令行中包含 libgsoap++.a? 编辑:

如果我不在命令行中包含 libgsoap++.a 我有:

undefined reference to `soap_embed'
/tmp/ccyeN0df.o: In function `soap_serialize_string(soap*, char* const*)':
TEST.cpp:(.text+0xb9de): undefined reference to `soap_reference'
/tmp/ccyeN0df.o: In function `soap_out_string(soap*, char const*, int, char* const*, char const*)':
TEST.cpp:(.text+0xba15): undefined reference to `soap_outstring'
/tmp/ccyeN0df.o: In function `soap_in_string(soap*, char const*, char**, char const*)':

I am working in ubuntu under c++ code. I am using gsoap in order to connect to a server. I've obtained all the data necesarry. I've also succeeded to connect to the server. Still I do have a question. Why do I need to write in the command line: g++ test_server.cpp -o testServ libgsoap++.a. Why do I need to include libgsoap++.a in my command line if I did include all the dependencies in my folder?
EDIT:

If I don't include libgsoap++.a in the command line i have:

undefined reference to `soap_embed'
/tmp/ccyeN0df.o: In function `soap_serialize_string(soap*, char* const*)':
TEST.cpp:(.text+0xb9de): undefined reference to `soap_reference'
/tmp/ccyeN0df.o: In function `soap_out_string(soap*, char const*, int, char* const*, char const*)':
TEST.cpp:(.text+0xba15): undefined reference to `soap_outstring'
/tmp/ccyeN0df.o: In function `soap_in_string(soap*, char const*, char**, char const*)':

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

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

发布评论

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

评论(1

说不完的你爱 2024-12-10 03:45:06

您需要告诉 g++ 您想要使用 -lgsoap++ 链接到 libgsoap++。

如果要链接 libgsopa++ 的非系统范围版本,则需要通过 -L 标志指定 g++ 的库路径。

简短说明:

您遇到链接时错误。编译成功并生成目标文件。在编译期间,您“承诺”(通过包含 gsoap 包含文件)soap_serialize_string 等存在于某处,并且目标代码可用。

现在链接器尝试从该目标文件创建可执行文件。它检查目标文件中的所有“承诺”并尝试解决它:用调用实际函数替换它。这个“实际功能”存在于哪里?在你的例子中,它是 libgsoap++.a。

因此,如果您不告诉链接器链接 libgsoap++.a,承诺就只是承诺,并且您有未定义的引用。

You need to tell g++ that you want to link against libgsoap++ using -lgsoap++.

If you want to link against non-system-wide version of libgsopa++, you need to specify library path to g++ via -L flag.

Short explanation:

You have link-time error. The compilation was successful and produced object files. During compilation time, you "promised" (by including gsoap include files) that soap_serialize_string et al exist somewhere, and object code is available.

Now linker tries to make an executable from that object files. It checks all that "promises" in object files and tries to resolve it: replace it with invoking actual functions. Where do this "actual functions" exist? In your case, it is libgsoap++.a.

So if you don't tell linker to link against libgsoap++.a, promises just remain promises, and you have undefined references.

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