编译 C++和 Ubuntu 11.10 上的 OpenSSL

发布于 2024-12-28 03:34:15 字数 969 浏览 3 评论 0原文

我在 Ubuntu 11.10 上编译 C++ 和 OpenSSL 项目时遇到严重问题。 编译命令是:

g++ -Wall -lssl -lm -lcrypto -I ./src ./src/server.cpp -o ./bin/server

我收到这些错误:

server.cpp:(.text+0x8ff): undefined reference to `RSA_new'
server.cpp:(.text+0x92d): undefined reference to `PEM_read_RSAPrivateKey'
server.cpp:(.text+0xa85): undefined reference to `RSA_size'
server.cpp:(.text+0xaa1): undefined reference to `RSA_size'
server.cpp:(.text+0xae7): undefined reference to `RSA_private_decrypt'
server.cpp:(.text+0xd84): undefined reference to `BF_set_key'
server.cpp:(.text+0xf1d): undefined reference to `BF_ecb_encrypt'
server.cpp:(.text+0x13c6): undefined reference to `BF_ecb_encrypt'
collect2: ld returned 1 exit status
make: *** [server] Error 1

我成功安装了 openssllibssl-dev 但问题仍然存在。 我尝试在内核 3.0 的 Linux Mint 12 上编译该项目,但遇到了同样的问题。 在我使用内核 2.6 的旧 Linux 操作系统上,该项目编译并运行良好(使用相同的 Makefile 和相同的源)。 请帮我!

I got a serious problem compiling my C++ and OpenSSL project on my Ubuntu 11.10.
The compiling command is:

g++ -Wall -lssl -lm -lcrypto -I ./src ./src/server.cpp -o ./bin/server

I receive these errors:

server.cpp:(.text+0x8ff): undefined reference to `RSA_new'
server.cpp:(.text+0x92d): undefined reference to `PEM_read_RSAPrivateKey'
server.cpp:(.text+0xa85): undefined reference to `RSA_size'
server.cpp:(.text+0xaa1): undefined reference to `RSA_size'
server.cpp:(.text+0xae7): undefined reference to `RSA_private_decrypt'
server.cpp:(.text+0xd84): undefined reference to `BF_set_key'
server.cpp:(.text+0xf1d): undefined reference to `BF_ecb_encrypt'
server.cpp:(.text+0x13c6): undefined reference to `BF_ecb_encrypt'
collect2: ld returned 1 exit status
make: *** [server] Error 1

I successfully installed openssl and libssl-dev but the problem persists.
I tried to compile the project on Linux Mint 12 with the kernel 3.0 and I had the same problem.
On my old Linux OS with the kernel 2.6 the project compiled and worked fine (using the same Makefile and the same sources).
Please help me!

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

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

发布评论

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

评论(3

妖妓 2025-01-04 03:34:15

通常,您需要在引用它们的代码后面添加 -l 链接标志。尝试

g++ -Wall  -I ./src ./src/server.cpp -o ./bin/server -lssl -lm -lcrypto

Generally you need to have the -l link flags after the code that references them. Try

g++ -Wall  -I ./src ./src/server.cpp -o ./bin/server -lssl -lm -lcrypto
青春如此纠结 2025-01-04 03:34:15

正如 此答案 的评论所述,链接器仅查找未定义的符号以按照列出参数的顺序包含。

也就是说,如果您的 cpp 文件使用这些库,则这些库必须列在 cpp 文件之后。

As the comment to this answer states, the linker only looks for undefined symbols to include in the order the parameters are listed.

That is, if your cpp file uses the libraries, the libraries have to be listed after the cpp file.

你的背包 2025-01-04 03:34:15

这些错误来自加密库,请检查 ssl 和加密库是否在 /usr/lib 中可用,或者检查您安装的位置(如果没有安装它们),并且您是否在编译命令中设置了 libssl 和 libcrypto 的库搜索路径?

Those error are from crypto library, check whether ssl and crypto libraries are available in /usr/lib or where ever u installed if not install them and have u set the library search path for libssl and libcrypto in your compiling command?

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