Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the installation instruction up-to-date? #531

Open
1 task done
tsurupin opened this issue Aug 13, 2024 · 4 comments
Open
1 task done

Is the installation instruction up-to-date? #531

tsurupin opened this issue Aug 13, 2024 · 4 comments
Labels

Comments

@tsurupin
Copy link

tsurupin commented Aug 13, 2024

  • Checked for duplicates

Describe the bug

I followed the instructions but encountered an error.
Is there anything else I need to install as a prerequisite?

$./bin/cling '#include <stdio.h>' 'printf("Hello World!\n")'

I got the following error:

$ ./bin/cling '#include <stdio.h>' 'printf("Hello World!\n")'
ERROR in cling::CIFactory::createCI():
  resource directory /home/xx/cling-build/lib/clang/16 not found!
In file included from input_line_3:1:
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
input_line_4:2:2: error: use of undeclared identifier 'printf'
 printf("Hello World!\n")

Expected behavior

it prints "Hello World!"

To Reproduce

Setup

  1. Cling version
    1.1~dev
  2. Operating system
    CentOS Stream 9
  3. How you obtained Cling, such as with cpt.py (also mention flags) / you built it yourself.
    Follow the instruction

Additional context

@tsurupin tsurupin added the bug label Aug 13, 2024
@tsurupin tsurupin changed the title Is the install instruction up-to-date? Is the installation instruction up-to-date? Aug 13, 2024
@z1gc
Copy link

z1gc commented Sep 9, 2024

I found the issue as well, and digged out there's missing the clang target in the build instruction,

cmake --build . --target clang

After the clang is built, stddef.h is located in cling-build/lib/clang/16/include/stddef.h and makes cling happy now.

@z1gc z1gc mentioned this issue Sep 9, 2024
@violet4
Copy link

violet4 commented Sep 18, 2024

@z1gc i'm a newbie to cmake and c++, would you be willing to briefly mention the steps you took to figure out the problem/solution? i'm trying to develop my cmake troubleshooting skills. i went back and tried to guess how you figured it out but am missing a gap in my knowledge.

it seems like /cling-build/lib/clang/16 not found! was the biggest hint, but how did you know that it could be solved by including a clang cmake target? did you know from that error message alone from intuition/experience, or did you have to dig any further?

@z1gc
Copy link

z1gc commented Sep 19, 2024

@z1gc i'm a newbie to cmake and c++, would you be willing to briefly mention the steps you took to figure out the problem/solution? i'm trying to develop my cmake troubleshooting skills. i went back and tried to guess how you figured it out but am missing a gap in my knowledge.

it seems like /cling-build/lib/clang/16 not found! was the biggest hint, but how did you know that it could be solved by including a clang cmake target? did you know from that error message alone from intuition/experience, or did you have to dig any further?

Just follow the original build instruction, and add one command to build the clang target:

# follow the README.md
git clone https://github.com/root-project/llvm-project.git
cd llvm-project
git checkout cling-latest
cd ..
git clone https://github.com/root-project/cling.git
mkdir cling-build && cd cling-build
cmake -DLLVM_EXTERNAL_PROJECTS=cling -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../cling/ -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm

# should build the clang
cmake --build . --target clang

# then the cling
cmake --build . --target cling

Hmmm, the solution is found by "guessing" however😂, yes the hint is truly the "lib/clang/16 not found", and as I thought this project is heavily based on LLVM which they forked one in https://github.com/root-project/llvm-project.git, and the LLVM itself is a monorepo contains everything includes clang, and this main cling repo doesn't contains any CMakeLists.txt or other build specs, therefore it must be reusing the LLVM's.

And the build command by the instructions show that as well, you're going to run the cmake with the LLVM's directory (../llvm-project/llvm) as the project (where CMakeLists.txt comes), and so I tried the clang target, it builds, and it runs🫢.

@wdscxsj
Copy link

wdscxsj commented Sep 21, 2024

Thanks to @z1gc for the tip! With Visual Studio 2022, clang compiles OK but cling fails. The errors start with:

Screenshot360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants