• <tfoot id='yQb7B'></tfoot>

    <i id='yQb7B'><tr id='yQb7B'><dt id='yQb7B'><q id='yQb7B'><span id='yQb7B'><b id='yQb7B'><form id='yQb7B'><ins id='yQb7B'></ins><ul id='yQb7B'></ul><sub id='yQb7B'></sub></form><legend id='yQb7B'></legend><bdo id='yQb7B'><pre id='yQb7B'><center id='yQb7B'></center></pre></bdo></b><th id='yQb7B'></th></span></q></dt></tr></i><div id='yQb7B'><tfoot id='yQb7B'></tfoot><dl id='yQb7B'><fieldset id='yQb7B'></fieldset></dl></div>
    <legend id='yQb7B'><style id='yQb7B'><dir id='yQb7B'><q id='yQb7B'></q></dir></style></legend>

      <small id='yQb7B'></small><noframes id='yQb7B'>

      • <bdo id='yQb7B'></bdo><ul id='yQb7B'></ul>

      1. 构建库时的 Clang 和未定义符号

        Clang and undefined symbols when building a library(构建库时的 Clang 和未定义符号)

        <small id='NUdxu'></small><noframes id='NUdxu'>

        <i id='NUdxu'><tr id='NUdxu'><dt id='NUdxu'><q id='NUdxu'><span id='NUdxu'><b id='NUdxu'><form id='NUdxu'><ins id='NUdxu'></ins><ul id='NUdxu'></ul><sub id='NUdxu'></sub></form><legend id='NUdxu'></legend><bdo id='NUdxu'><pre id='NUdxu'><center id='NUdxu'></center></pre></bdo></b><th id='NUdxu'></th></span></q></dt></tr></i><div id='NUdxu'><tfoot id='NUdxu'></tfoot><dl id='NUdxu'><fieldset id='NUdxu'></fieldset></dl></div>

        • <legend id='NUdxu'><style id='NUdxu'><dir id='NUdxu'><q id='NUdxu'></q></dir></style></legend>

          <tfoot id='NUdxu'></tfoot>
                <tbody id='NUdxu'></tbody>
                <bdo id='NUdxu'></bdo><ul id='NUdxu'></ul>

                1. 本文介绍了构建库时的 Clang 和未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个 C++ 框架,当我在 OSX 上使用 Clang 编译它时会出现一些问题.

                  I'm working on a C++ framework, and there's a few issues when I compile it on OSX with Clang.

                  首先,我正在使用一些其他库,例如 openssl,并且 clang 抱怨在我构建库时某些符号没有得到解决.它们不应该是:这些库将与最终的二进制文件链接,它不应该发生在中介上.

                  First of, I'm using some other libraries, such as openssl, and clang complains that some symbols aren't solved when I build the library. They shouldn't be: these libraries will be linked with the final binary, it shouldn't happen on an intermediary.

                  然后,还有一些方法和变量应该在客户端"二进制文件中实现……使用 GCC,没有问题,但 Clang 也抱怨这些符号在编译过程中无法解决.

                  Then, there's also a few methods and variables that are supposed to be implemented in the "client" binary... with GCC, no problems, but Clang also complains that these symbols can't be solved during compilation.

                  怎么会?我该怎么办?

                  这是我的 CMakeLists.txt,以防万一:

                  Here's my CMakeLists.txt in case that can be useful:

                  cmake_minimum_required(VERSION 2.8)
                  
                  project(crails_project)
                  
                  set(CMAKE_CXX_FLAGS "-std=c++0x -Wall -Wno-deprecated-declarations -pedantic -DASYNC_SERVER -DSERVER_DEBUG -DUSE_MONGODB_SESSION_STORE")
                  
                  find_package(cppnetlib REQUIRED)
                  
                  include_directories(include /usr/local/include ${CPPNETLIB_INCLUDE_DIRS} .)
                  
                  file(GLOB crails_core
                       src/*.cpp)
                  
                  file(GLOB crails_sql
                       src/sql/*.cpp)
                  
                  file(GLOB crails_mongodb
                       src/mongodb/*.cpp)
                  
                  add_library(crails-core    SHARED ${crails_core})
                  add_library(crails-sql     SHARED ${crails_sql})
                  add_library(crails-mongodb SHARED ${crails_mongodb})
                  

                  这是崩溃的命令:

                  /usr/bin/c++  -std=c++0x -Wall -Wno-deprecated-declarations -pedantic -DASYNC_SERVER -DSERVER_DEBUG -DUSE_MONGODB_SESSION_STORE -dynamiclib -Wl,-headerpad_max_install_names   -o libcrails-core.dylib -install_name /Users/michael/Personal/crails/build/libcrails-core.dylib CMakeFiles/crails-core.dir/src/assets.cpp.o CMakeFiles/crails-core.dir/src/cgi2params.cpp.o CMakeFiles/crails-core.dir/src/cipher.cpp.o [...]
                  

                  这是我得到的两种错误:

                  And here are the two kinds of error I get:

                  体系结构 x86_64 的未定义符号:

                  Undefined symbols for architecture x86_64:

                    "_BIO_ctrl", referenced from:
                        Cipher::encode_base64(unsigned char*, unsigned int) const in cipher.cpp.o
                  

                  第二个:

                    NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
                    "vtable for boost::detail::thread_data_base", referenced from:
                        boost::detail::thread_data_base::thread_data_base() in server.cpp.o
                  

                  推荐答案

                  解决了!Clang 需要接收选项 -undefined dynamic_lookup 以在编译库时忽略丢失的符号.

                  Solved it ! Clang needs to receive the option -undefined dynamic_lookup to ignore missing symbols when compiling a library.

                  将此添加到 CMakeFile.txt 以产生预期的效果:

                  Add this to the CMakeFile.txt to produce the expected effect:

                  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
                    set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
                  endif()
                  

                  这篇关于构建库时的 Clang 和未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)
                    <bdo id='KAN1P'></bdo><ul id='KAN1P'></ul>

                      • <legend id='KAN1P'><style id='KAN1P'><dir id='KAN1P'><q id='KAN1P'></q></dir></style></legend>
                        <i id='KAN1P'><tr id='KAN1P'><dt id='KAN1P'><q id='KAN1P'><span id='KAN1P'><b id='KAN1P'><form id='KAN1P'><ins id='KAN1P'></ins><ul id='KAN1P'></ul><sub id='KAN1P'></sub></form><legend id='KAN1P'></legend><bdo id='KAN1P'><pre id='KAN1P'><center id='KAN1P'></center></pre></bdo></b><th id='KAN1P'></th></span></q></dt></tr></i><div id='KAN1P'><tfoot id='KAN1P'></tfoot><dl id='KAN1P'><fieldset id='KAN1P'></fieldset></dl></div>
                      • <small id='KAN1P'></small><noframes id='KAN1P'>

                        <tfoot id='KAN1P'></tfoot>

                            <tbody id='KAN1P'></tbody>