当我使用 OpenSSL 制作 python 模块时出现链接问题 +斯威格
我有一个 C 文件 dtls_udp_echo.c
,在其中使用 SSL 函数。我正在尝试使用 SWIG 为该文件创建一个 Python 包装器。我已完成以下步骤:
1)创建接口文件udp.i
:
%module udp
%{
/* Put header files here or function declarations like below */
#define SWIG_FILE_WITH_INIT
#include "dtls_udp_echo.h"
%}
int THREAD_setup();
int THREAD_cleanup();
int handle_socket_error();
int generate_cookie(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len);
int verify_cookie(SSL *ssl, unsigned char *cookie, unsigned int cookie_len);
int dtls_verify_callback (int ok, X509_STORE_CTX *ctx) ;
void* connection_handle(void *info);
void start_server(int port, char *local_address);
void start_client(char *remote_address, char *local_address, int port, int length, int messagenumber);
2)运行命令swig -python udp.i
。
3) 运行命令gcc -O2 -fPIC -c dtls_udp_echo.c -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto -lssl。包含和库的路径是正确的,我检查了!
4)运行命令 gcc -O2 -fPIC -c udp_wrap.c -I/usr/include/python2.5 -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto -lssl。
5) 运行命令gcc -shared dtls_udp_echo.o udp_wrap.o -o _udp.so
。
似乎完成正常,没有报告任何错误。但是,当我尝试导入模块时,我得到以下回溯:
>>> import udp
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "udp.py", line 28, in <module>
> import _udp ImportError: ./_udp.so: undefined symbol:
> SSL_get_rbio
任何人都可以帮我解决这个问题吗?
I have a C file dtls_udp_echo.c
in which I use SSL functions. I am trying to create a Python wrapper for this file using SWIG. I've done the following steps:
1) Created an interface file udp.i
:
%module udp
%{
/* Put header files here or function declarations like below */
#define SWIG_FILE_WITH_INIT
#include "dtls_udp_echo.h"
%}
int THREAD_setup();
int THREAD_cleanup();
int handle_socket_error();
int generate_cookie(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len);
int verify_cookie(SSL *ssl, unsigned char *cookie, unsigned int cookie_len);
int dtls_verify_callback (int ok, X509_STORE_CTX *ctx) ;
void* connection_handle(void *info);
void start_server(int port, char *local_address);
void start_client(char *remote_address, char *local_address, int port, int length, int messagenumber);
2) Run the command swig -python udp.i
.
3) Run the command gcc -O2 -fPIC -c dtls_udp_echo.c -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto -lssl
. The path to the include and library is correct, I checked it!
4) Run the command gcc -O2 -fPIC -c udp_wrap.c -I/usr/include/python2.5 -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto -lssl
.
5) Run the command gcc -shared dtls_udp_echo.o udp_wrap.o -o _udp.so
.
It seems to complete OK as no errors are reported. But, when I try to import the module, I get the following traceback:
>>> import udp
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "udp.py", line 28, in <module>
> import _udp ImportError: ./_udp.so: undefined symbol:
> SSL_get_rbio
Can anybody help me to fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它找不到 OpenSSL 库。将其添加到您的 ld 搜索路径中;有关详细信息,请参阅 ldconfig(8) 手册页。
It can't find the OpenSSL library. Add it to your ld search path; see the
ldconfig(8)
man page for details.