日期:2014-05-16  浏览次数:20725 次

新手:Linux下使用第三方C库(openssl),是调用.so文件还是直接调用.h文件?
新手:Linux下使用第三方C库(openssl),是调用.so文件还是直接调用.h文件?

------解决方案--------------------
头文件和库文件都是必须的呀
------解决方案--------------------
.a是静态链接库,.so是动态的,两者都要include.h文件,静态的可以直接调用它里面的方法,动态库要
#include <dlfcn.h> 
#include <stdio.h> 

int main ( int argc, char * argv[] ) 

void * libc; 
void ( * printf_call ) (); 

if ( ( libc = dlopen( "/lib/libc.so.6", RTLD_LAZY ) ) != 0 ) 

printf_call = dlsym( libc, "printf" ); 
( *printf_call )( "hello, world\n" ); 

return 0; 
} /* end of main */ 
参考资料:http://www.linuxforum.net/forum/showflat.php?Board=program&Number=124803

------解决方案--------------------
如果你要调用openssl的函数接口,包含.h文件就可以了,我当初写openssl的程序的时候就直接包含的.h文件。