#project can't find files from llvm

56 messages ยท Page 1 of 1 (latest)

tired root
#

I'm running the following

clang++ -o eva-llvm `llvm-config --cxx-flags --ldflags --system-libs --libs core` EvaLLVM.cpp

and getting the following

././src/EvaLLVM.h:6:10: fatal error: 'llvm/IR/IRBuilder.h' file not found
    6 | #include "llvm/IR/IRBuilder.h"
      |          ^~~~~~~~~~~~~~~~~~~~~

i have the following when printing --cxxflags

interpretations@Daniels-MacBook-Pro eva-llvm % llvm-config --cxxflags                                                   
-I/opt/homebrew/Cellar/llvm/19.1.5/include -std=c++17 -stdlib=libc++   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

And can validate that the file is there with ls
So why can't clang find it?

loud onyxBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

summer vortex
#

is /opt/homebrew/Cellar/llvm/19.1.5/include populated as you'd expect?

tired root
#

yes

#

it has llvm/IR/IRBuilder.h in it

summer vortex
#

maybe try #include <llvm/IR/IRBuilder.h>

tired root
#

same error

summer vortex
#

can you which clang++

tired root
#

/opt/homebrew/opt/llvm/bin/clang++

summer vortex
#

out of curiosity does /opt/homebrew/Cellar/llvm/19.1.5/bin/clang++ exist

#

I'm wondering if it's using the wrong clang

tired root
#

yeah

#

i tried moving it somewhere else which didn't help

summer vortex
#

I was going to suggest trying /opt/homebrew/Cellar/llvm/19.1.5/bin/clang++ -o eva-llvm `llvm-config --cxx-flags --ldflags --system-libs --libs core` EvaLLVM.cpp

tired root
#

moved it back and got the same error

summer vortex
#

hmm

#

well, as a last resort you can try running clang with verbose mode to see what flags it's actually getting and what paths it's searching for headers

tired root
#

is it weird that it's using clang-19 instead of clang++?

summer vortex
#

I don't think so, it's the same binary (generally just a sym link, the clang binary handles both languages)

tired root
#

hmm

summer vortex
# tired root

the clang invocation here doesn't have any -I flags

#

it does have -internal-isystem /opt/homebrew/Cellar/llvm/19.1.5/lib/clang/19/include though

#

but that's not quite what llvm-config spat out

#

can you send the full output of llvm-config --cxx-flags --ldflags --system-libs --libs core

tired root
#

oh weird

#

it's not printing the right thing naymore

#

help options

#

nvm fixed

#
interpretations@Daniels-MacBook-Pro eva-llvm % llvm-config --cxxflags --ldflags --system-libs --libs core
-I/opt/homebrew/Cellar/llvm/19.1.5/include -std=c++17 -stdlib=libc++   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-L/opt/homebrew/Cellar/llvm/19.1.5/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names
-lLLVM-19
loud onyxBOT
#

@tired root

It looks like you may have code formatting errors in your message

Note: Make sure to use back-ticks (`) and not quotes (')
Note: Make sure to specify a highlighting language, e.g. `cpp`, after the back-ticks

Markup

```cpp
int main() {}
```

Result
int main() {}
summer vortex
#

so llvm-config --cxx-flags --ldflags --system-libs --libs core wrote nothing to stdout only stderr

tired root
#

yeah i have all these new errors now

summer vortex
#

yay

#

new errors are good

tired root
#

lol yeah

#
././src/EvaLLVM.h:29:22: error: no matching constructor for initialization of 'std::unique_ptr<llvm::Module>'
   29 |             module = std::unique_ptr<llvm::Module>("EvaLLVM", *ctx);
      |                      ^                             ~~~~~~~~~~~~~~~
#

formatting... the carat is pointing at "EvalLLVM" string arg

#
void moduleInit() {
            ctx = std::unique_ptr<llvm::LLVMContext>();
            module = std::unique_ptr<llvm::Module>("EvaLLVM", *ctx);
            builder = std::unique_ptr<llvm::IRBuilder<>>(*ctx);
        }
summer vortex
#

I don't see the problem

#

what does it say about why there was no match

tired root
#

do i need to include something to have access to std::unique_ptr?

#

did a screenshot to try and keep the formatting

#

and here's the whole giant error... it has another issue in teh other place i try to use unique_ptr

#

interesting it cares about the bottom two lines but not the first usage

#
ctx = std::unique_ptr<llvm::LLVMContext>();
module = std::unique_ptr<llvm::Module>("EvaLLVM", *ctx);
builder = std::unique_ptr<llvm::IRBuilder<>>(*ctx);
summer vortex
#

oh, use std::make_unique ๐Ÿ˜›

#

std::unique_ptr<llvm::Module>("EvaLLVM", *ctx); doesn't forward arguments to any constructor, it expects to take a pointer or instance of the object

tired root
#

that was it! thanks!

#

!solved

loud onyxBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity