Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:44:38+00:00 2026-06-15T13:44:38+00:00

I get these code from here. Follow the steps. But have errors when I

  • 0

I get these code from here. Follow the steps. But have errors when I make

using namespace clang;
int main()
{
    CompilerInstance ci;
    ci.createDiagnostics(0,NULL); // create DiagnosticsEngine
    ci.createFileManager();  // create FileManager
    ci.createSourceManager(ci.getFileManager()); // create SourceManager
    ci.createPreprocessor();  // create Preprocessor
    const FileEntry *pFile = ci.getFileManager().getFile("hello.c");
    ci.getSourceManager().createMainFileID(pFile);
    ci.getPreprocessor().EnterMainSourceFile();
    ci.getDiagnosticClient().BeginSourceFile(ci.getLangOpts(), &ci.getPreprocessor());
    Token tok;
    do {
        ci.getPreprocessor().Lex(tok);
        if( ci.getDiagnostics().hasErrorOccurred())
            break;
        ci.getPreprocessor().DumpToken(tok);
        std::cerr << std::endl;
    } while ( tok.isNot(clang::tok::eof));
    ci.getDiagnosticClient().EndSourceFile();
}

The Makefile for it.

    CXX := g++
    RTTIFLAG := -fno-rtti
    CXXFLAGS := $(shell llvm-config --cxxflags) $(RTTIFLAG)
    LLVMLDFLAGS := $(shell llvm-config --ldflags --libs)
    DDD := $(shell echo $(LLVMLDFLAGS))
    SOURCES = main.cpp
    OBJECTS = $(SOURCES:.cpp=.o)
    EXES = $(OBJECTS:.o=)
    CLANGLIBS = \
            -L /usr/local/lib \
            -lclangFrontend \
            -lclangParse \
            -lclangSema \
            -lclangAnalysis \
            -lclangAST \
            -lclangLex \
            -lclangBasic \
            -lclangDriver \
            -lclangSerialization \
            -lLLVMMC \
            -lLLVMSupport \
    all: $(OBJECTS) $(EXES)
    %: %.o
    $(CXX) -o $@ $< $(CLANGLIBS) $(LLVMLDFLAGS)

The error messages I get when I make.

g++ -I/usr/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS   -fvisibility-inlines-hidden -fno-exceptions -fPIC -Woverloaded-virtual -Wcast-qual -fno-rtti   -c -o main.o main.cpp
main.cpp:1:21: error: ‘clang’ is not a namespace-name
main.cpp:1:26: error: expected namespace-name before ‘;’ token
main.cpp: In function ‘int main()’:
main.cpp:4:9: error: ‘CompilerInstance’ was not declared in this scope
main.cpp:4:26: error: expected ‘;’ before ‘ci’
main.cpp:5:9: error: ‘ci’ was not declared in this scope
main.cpp:5:32: error: ‘NULL’ was not declared in this scope
main.cpp:9:15: error: ‘FileEntry’ does not name a type
main.cpp:10:48: error: ‘pFile’ was not declared in this scope
main.cpp:13:9: error: ‘Token’ was not declared in this scope
main.cpp:13:15: error: expected ‘;’ before ‘tok’
main.cpp:15:38: error: ‘tok’ was not declared in this scope
main.cpp:19:13: error: ‘cerr’ is not a member of ‘std’
main.cpp:19:26: error: ‘endl’ is not a member of ‘std’
main.cpp:20:19: error: ‘tok’ was not declared in this scope
main.cpp:20:29: error: ‘clang’ has not been declared
make: *** [main.o] Error 1

I am new to C++. I am sorry if this question is too simple. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:44:40+00:00Added an answer on June 15, 2026 at 1:44 pm

    Have you included relevant headers in your implementation file, for example:

    #include <CompilerInstance.h>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

text = urllib.urlopen('www.text.com').read() frase = re.search(your text here(.*), text).group() With these code, I get
I have a test application here which you can use: Please follow steps below
i have some SQL code that is inserting values from another (non sql-based) system.
I installed grappelli.dashboard. Follow all the steps, but still the navigation is not display.After
I have the following code: <iframe> <div id=inner_div> Here's some text! </div> </iframe> I
I try to follow the facebook-android tutorial from here: https://developers.facebook.com/docs/mobile/android/build/#sample I am working in
I'm trying to follow the documentation to get started with celery, but running into
I have some code that pulls HTML from an external source: $doc = new
I have a follow up question on the accepted answer given here: Two models
I am using the jQuery tree from here https://github.com/pioz/jquery-tree#readme The problem is rendering of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.