make C代码时libcrypto.a出错

时间:2014-10-08 14:24:10

标签: c linux ssl openssl daemon

我尝试在Linux上构建独立服务器,请遵循以下指示: https://github.com/kazuho/h2o 但是当我键入" make h2o"时,我收到了一个错误:

    Linking C executable h2o
    /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
    dso_dlfcn.c:(.text+0x21): undefined reference to `dlopen'
    dso_dlfcn.c:(.text+0x34): undefined reference to `dlsym'
    dso_dlfcn.c:(.text+0x3f): undefined reference to `dlclose'
    /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
    dso_dlfcn.c:(.text+0x354): undefined reference to `dlsym'
    dso_dlfcn.c:(.text+0x3fb): undefined reference to `dlerror'
    /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
    dso_dlfcn.c:(.text+0x474): undefined reference to `dlsym'
    dso_dlfcn.c:(.text+0x52e): undefined reference to `dlerror'
    /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
    dso_dlfcn.c:(.text+0x5a4): undefined reference to `dlopen'
    dso_dlfcn.c:(.text+0x612): undefined reference to `dlclose'
    dso_dlfcn.c:(.text+0x640): undefined reference to `dlerror'
    /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
    dso_dlfcn.c:(.text+0x6be): undefined reference to `dladdr'
    dso_dlfcn.c:(.text+0x721): undefined reference to `dlerror'
    /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
    dso_dlfcn.c:(.text+0x77a): undefined reference to `dlclose'
    collect2: ld returned 1 exit status
    make[3]: *** [h2o] Error 1
    make[2]: *** [CMakeFiles/h2o.dir/all] Error 2
    make[1]: *** [CMakeFiles/h2o.dir/rule] Error 2
    make: *** [h2o] Error 2

任何人都可以告诉我具体如何解决? 非常感谢!

1 个答案:

答案 0 :(得分:1)

如评论中所述,最终的可执行文件应与dl库链接。虽然并非所有系统都需要这样,但是h2o的上游作者应该修复它。

如果您正在寻求快速和彻底的修复,请打开CMakeLists.txt文件并替换该行:

TARGET_LINK_LIBRARIES(h2o ${OPENSSL_LIBRARIES} ${LIBYAML_LIBRARIES} pthread)

TARGET_LINK_LIBRARIES(h2o ${OPENSSL_LIBRARIES} ${LIBYAML_LIBRARIES} pthread -ldl)