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

ERROR: Dependency Clang not found during local build of hdoc #40

Open
DerNils-git opened this issue Mar 3, 2023 · 8 comments
Open

ERROR: Dependency Clang not found during local build of hdoc #40

DerNils-git opened this issue Mar 3, 2023 · 8 comments

Comments

@DerNils-git
Copy link

Hi everyone,

I wanted to have a try with hdoc locally and build the project using meson.

Using clang13 on openSUSE Leap 15.4 I recieve the following error.
meson.build:14:0: ERROR: Dependency Clang not found: CMake: invalid module clangTooling for Clang.

But in the build configuration output the clang compiler is used.

The Meson build system
Version: 0.59.4
Build type: native build
Project name: hdoc
Project version: 1.4.0
C compiler for the host machine: cc (clang 13.0.1 "clang version 13.0.1")
C linker for the host machine: cc ld.bfd 2.39.0.20220810-150100
C++ compiler for the host machine: c++ (clang 13.0.1 "clang version 13.0.1")
C++ linker for the host machine: c++ ld.bfd 2.39.0.20220810-150100
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found CMake: /bin/cmake (3.23.20220304)
WARNING: Ignoring LLVM CMake dependency because dynamic was requested
llvm-config found: YES (/usr/bin/llvm-config) 13.0.1
Run-time dependency LLVM found: YES 13.0.1
Run-time dependency clang found: NO 

I don't have any experience using meson therefore maybe I can receive some help with the configuration error from you.

Thanks in advance.

@hdoc
Copy link
Owner

hdoc commented Mar 3, 2023

Hello!

I believe this error is related to the way you have the LLVM and clang dependencies installed on your system. We don't currently test on openSUSE so I can't precisely say what the issue is, but you can see a similar issue for Ubuntu here.

Having the clang compiler is not enough because hdoc relies on libclang, which is a separate library that usually isn't included with clang by most Linux distributions. I'm not sure exactly where you can get that library on openSUSE and I don't have a system to test with, but a brief search online seems to show that openSUSE has a couple packages that you should try:

Note: you should use LLVM 14 and not LLVM 13 when trying to build hdoc as there is a unit test that will fail on LLVM 13.

Please try this out and report back if it works so that other users can benefit!

Thank you

@DerNils-git DerNils-git changed the title Error trying to build hdoc using meson locally on openSUSE ERROR: Dependency Clang not found during local build of hdoc Mar 5, 2023
@DerNils-git
Copy link
Author

DerNils-git commented Mar 5, 2023

Hi,

the Bug seems to be caused through the definition of clang_modules in the meson.build configuration file.
CMake is the default type to look for dependencies. But CMake does not exports any of the given modules on openSUSE.

I think, CMake searches in the configuration file /usr/lib64/cmake/clang/ClangConfig.cmake by default. But this file provides only the target libclang and a lot of additional binaries. The other modules in the list are not provided and can not be found by CMake and therefore not provided for the build in meson. This causes e.g. the Error CMake: invalid module clangTooling for Clang.

This is the patch of git diff which solved the problem

 dep_llvm = dependency('LLVM', include_type: 'system')
-clang_modules = [
-  'clangTooling',
-  'clangToolingInclusions',
-  'clangToolingCore',
-  'clangFrontend',
-  'clangAST',
-  'clangIndex',
-  'clangBasic',
-]
+clang_modules = ['libclang']
 dep_clang = dependency('Clang', include_type: 'system', method: 'cmake', modules: clang_modules)

I hope this answer is helpful

@DerNils-git
Copy link
Author

btw, you are right that one of the unit tests fails, since I am using LLVM13 and not LLVM14.

But for now I will try LLVM13 until I update to Leap 15.5 which provides an official package for LLVM14.

@DerNils-git
Copy link
Author

One more error which I encountered.
If I try to build hdoc not in a subdirectory of the source directory I receive the error below during linking.

Should we have a look into this in a different issue? But since I can build the project, if I work in a subdirectory this does not really have a high priority for me. Might just be interesting to solve so that other users don't run into the same problem.

FAILED: hdoc 
c++  -o hdoc hdoc.p/src_main.cpp.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group libhdoc.a subprojects/cmark-gfm/libcmark-gfm.a subprojects/spdlog/libspdlog.a -lLLVM -pthread /usr/lib64/libLLVM.so.13 /usr/lib64/libclang-cpp.so.13 /usr/lib64/libclang.so.13 /usr/bin/../lib64/gcc/x86_64-suse-linux/11/../../../../lib64/libz.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so -lLLVM -Wl,--end-group
/usr/bin/ld: libhdoc.a(src_frontend_Frontend.cpp.o): in function `Frontend':
~/codes/build/hdoc-clang/../../hdoc/src/frontend/Frontend.cpp:45: undefined reference to `___site_content_oss_md'
/usr/bin/ld: libhdoc.a(src_serde_HTMLWriter.cpp.o): in function `HTMLWriter':
/home/nils/codes/build/hdoc-clang/../../hdoc/src/serde/HTMLWriter.cpp:88: undefined reference to `___assets_apple_touch_icon_png_len'
/usr/bin/ld: ~/codes/build/hdoc-clang/../../hdoc/src/serde/HTMLWriter.cpp:88: undefined reference to `___assets_apple_touch_icon_png'

@grhawk
Copy link

grhawk commented May 5, 2023

On ubuntu, you need to install the dependencies as following:

apt install build-essential meson llvm cmake clang clang-dev libclang-dev libclang-cpp-dev xxd pkg-config openssl libssl-dev

I suppose you can map these to Suse. You can also see a docker file that build hdoc here or download the related image from hub.docker.

@hdoc
Copy link
Owner

hdoc commented May 9, 2023

Hey Nils, I apologize for the late response. Thanks for sharing what worked for you, hopefully it will be useful for other users who try to use hdoc on SUSE. Every distro packaging LLVM differently makes it difficult to test but I'm glad you were able to get it running.

As for your second build error, could you share some more details? Those files that are missing are basically embedded assets such as CSS styling and so on which are generated at build time and linked into the program. I suspect what might be happening there is that our build system isn't using absolute paths which could cause the build to fail. Any more detail you could provide so we could fix this issue would be helpful, in particular reproduction instructions.

Thank you.

@DerNils-git
Copy link
Author

The workflow is acutally the same as described in the README.md

I just substitute ninja -C ./build through ninja -C <PATH/TO/MY/BUILD/DIRECTORY>

!> meson ../build/hdoc-clang
The Meson build system
Version: 0.59.4
Source dir: /home/nils/codes/hdoc
Build dir: /home/nils/codes/build/hdoc-clang
Build type: native build
Project name: hdoc
Project version: 1.4.0
C compiler for the host machine: cc (clang 13.0.1 "clang version 13.0.1")
C linker for the host machine: cc ld.bfd 2.39.0.20220810-150100
C++ compiler for the host machine: c++ (clang 13.0.1 "clang version 13.0.1")
C++ linker for the host machine: c++ ld.bfd 2.39.0.20220810-150100
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found CMake: /home/nils/bin/cmake (3.23.20220304)
WARNING: Ignoring LLVM CMake dependency because dynamic was requested
llvm-config found: YES (/usr/bin/llvm-config) 13.0.1
Run-time dependency LLVM found: YES 13.0.1
Run-time dependency clang (modules: libclang) found: YES 13.0.1
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency zlib found: YES 1.2.11
Program xxd found: YES (/usr/bin/xxd)
Run-time dependency threads found: YES
Run-time dependency openssl found: YES 1.1.1l

<FURTHER/SUBPROJECT/CONFIG/OUTPUT>

Build targets in project: 6

hdoc 1.4.0

  Subprojects
    argparse   : YES
    cmark-gfm  : YES
    cpp-httplib: YES
    ctml       : YES
    doctest    : YES
    rapidjson  : YES
    spdlog     : YES
    toml++     : YES

Then ninja -C ../build/hdoc-clang which returns the above error during linking.

Is this sufficient for reproducibility of the bug?

@hdoc
Copy link
Owner

hdoc commented Oct 2, 2023

The issue with the assets not being available is because hdoc is being built in a subdirectory. This was pointed out by @no92 in a separate PR and we have a fix for it in our internal repo of hdoc which will be part of the next release. I'll make a comment on this issue when that happens.

As a workaround, you can locally apply the patch supplied by @no92 here which should fix the issue. Make sure the version of xxd is new enough to support the -name argument.

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

No branches or pull requests

3 participants