[cfe-dev] Undefined symbols for architecture x86_64 when compile newFrontendActionFactory with clang 5.0.

彬杰 via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 5 02:04:52 PDT 2017


My Code is : 
===============================================================================================
void *threadRun(void *arg)
{
    struct threadParam *param = (struct threadParam *) arg;
    ClangTool clangTool(*param->cdb, *param->taskList);
    pthread_mutex_lock(&Global::actionMutex);
    unique_ptr<FrontendActionFactory> factory = newFrontendActionFactory<GodEyesFrontendAction>(); // Error happens here
    ToolAction* action;
    if (factory != NULL) {
        action = factory.get();
    }
    pthread_mutex_unlock(&Global::actionMutex);
    if (factory != NULL) {
        clangTool.run(action);
    
    }
    return (void*)1;
}

===============================================================================================
it can compile and link well in clang 3.7, but when I upgrade clang to 5.0 ,  it link fails.  I don't know what's wrong with this;
Please help me out here.Any idea will be appreciated! thanks!!!


ERROR Message :  
===============================================================================================
Undefined symbols for architecture x86_64:   
    "typeinfo for clang::ASTConsumer", referenced from:   
    typeinfo for GodEyesASTConsumer in GodEyes.cpp.o   
    "typeinfo for clang::ASTFrontendAction", referenced from:   
    typeinfo for GodEyesFrontendAction in GodEyes.cpp.o   
    "typeinfo for clang::tooling::FrontendActionFactory", referenced from:   
    typeinfo for std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> >   clang::tooling::newFrontendActionFactory<GodEyesFrontendAction>  ()::SimpleFrontendActionFactory in GodEyes.cpp.o   
ld: symbol(s) not found for architecture x86_64   
clang: error: linker command failed with exit code 1 (use -v to see invocation)   
ninja: build stopped: subcommand failed.   
=============================================================================================== 




My CMakeLists.txt is as below: 
===============================================================================================
cmake_minimum_required (VERSION 2.8) 


project(main)   
set(main_VERSION 3.1)   


configure_file (   
  "${PROJECT_SOURCE_DIR}/config.h.in"   
  "${PROJECT_SOURCE_DIR}/config.h"   
  )   


set(CMAKE_C_COMPILER "/usr/bin/clang")   
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")   
set(CMAKE_AR "/usr/bin/llvm-ar")   
set(CMAKE_LINKER "/usr/bin/llvm-ld")   
set(CMAKE_NM "/usr/bin/llvm-nm")   
set(CMAKE_OBJDUMP "/usr/bin/llvm-objdump")   
set(CMAKE_RANLIB "/usr/bin/llvm-ranlib")   
set(CLANG_ROOT "/Users/baixx/clang-llvm/build/lib/clang/3.9.0/include")   
set(LLVM_LINK_COMPONENTS support)   
set(LLVM_USED_LIBS clangTooling clangBasic clangAST)   


set(CMAKE_BUILD_TYPE "Release")   
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")   
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -DCMAKE_OSX_ARCHITECTURES=x86_64")   


aux_source_directory(. DIR_SRCS)   
aux_source_directory(rules RULE_SRCS)   
add_executable (main-core ${DIR_SRCS} ${RULE_SRCS})   
target_link_libraries(main-core clangTooling curl) 
=========================================================================================== 


Please help me out here.Any idea will be appreciated! thanks!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170905/b151eb28/attachment.html>


More information about the cfe-dev mailing list