<div dir="ltr"><br><div><br></div><div><br></div><div>Sorry for the late reply. I tried <span style="color:rgb(0,0,0);font-family:monospace">LIBGL_ALWAYS_INDIRECT=1 ./helloworld from stackoverflow.</span></div><div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><div><span style="color:rgb(0,0,0);font-family:monospace">I attached LD_DEBUG=libs output with Qt and without Qt to this email.</span></div><div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><span style="font-family:monospace"><br></span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 15, 2022 at 2:02 AM Sven Brauch <<a href="mailto:mail@svenbrauch.de">mail@svenbrauch.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
which solution did you try? The actual answer (not the comments) sounds <br>
plausible, we have heard of similar issues before, but that might not be <br>
easy to do on your system.<br>
<br>
Maybe you can get further info with LD_DEBUG=libs set and checking if <br>
indeed two different versions of libclang are loaded along the road?<br>
<br>
Greetings,<br>
Sven<br>
<br>
<br>
On 4/14/22 23:26, Enes Albay wrote:<br>
> <br>
> I guess I found the reason for the error. Clang works if I comment out <br>
> the line "QApplication app(argc, argv);" Otherwise It gives error like this:<br>
> <br>
> $ ./helloworld<br>
> 4<br>
> Unable to parse translation unit. Quitting.<br>
> <br>
> As far as I understand this bug is related to this one <br>
> <a href="https://stackoverflow.com/questions/17953156/cannot-use-libclang-with-qt" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/17953156/cannot-use-libclang-with-qt</a> <br>
> <<a href="https://stackoverflow.com/questions/17953156/cannot-use-libclang-with-qt" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/17953156/cannot-use-libclang-with-qt</a>><br>
> <br>
> But the solution suggested in stackoverflow does not work for me. Do you <br>
> have any idea ?<br>
> <br>
> /******************MAIN **************************/<br>
> #include <QApplication><br>
> #include "clang-c/Index.h"<br>
> <br>
> #include <iostream><br>
> using namespace std;<br>
> <br>
> int main (int argc, char *argv[])<br>
> {<br>
>      QApplication app(argc, argv);<br>
>     CXIndex index = clang_createIndex(0, 0);<br>
>    CXTranslationUnit unit = nullptr;<br>
> <br>
>    CXErrorCode code = clang_parseTranslationUnit2(<br>
>      index,<br>
>      "/media/enes/MyFiles/programming/cpp/cmakeExamples/ex1/main.cpp", <br>
> nullptr, 0,<br>
>      nullptr, 0,<br>
>      CXTranslationUnit_None, &unit);<br>
> <br>
>    cerr << code << endl;<br>
>    if (code != CXError_Success) {<br>
>      cerr << "Unable to parse translation unit. Quitting." << endl;<br>
>      exit(-1);<br>
>    }<br>
> <br>
>    return 0;<br>
> }<br>
> <br>
> <br>
> # CMakeLists.txt<br>
> <br>
> cmake_minimum_required(VERSION 3.0)<br>
> <br>
> project (helloworld)<br>
> <br>
> set(LLVM_ROOT /usr/lib/llvm-13)<br>
> set(QT_MIN_VERSION "5.15.2")<br>
> <br>
> # Find Qt modules<br>
> find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS<br>
>      Core    # QCommandLineParser, QStringLiteral<br>
>      Widgets # QApplication<br>
> )<br>
> <br>
> find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config HINTS <br>
> ${LLVM_ROOT}/bin DOC "llvm-config executable" NO_DEFAULT_PATH)<br>
> message(${LLVM_CONFIG_EXECUTABLE})<br>
> set(Clang_DIR /usr/lib/llvm-13/cmake)<br>
> <br>
> # Find CMake file for Clang<br>
> find_package(Clang REQUIRED)<br>
> <br>
> execute_process(<br>
>          COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir<br>
>          OUTPUT_VARIABLE LLVM_INCLUDE_DIRS<br>
>          OUTPUT_STRIP_TRAILING_WHITESPACE<br>
>          )<br>
> <br>
> message(${LLVM_INCLUDE_DIRS})<br>
> <br>
> execute_process(<br>
>          COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir<br>
>          OUTPUT_VARIABLE LLVM_LIBRARY_DIRS<br>
>          OUTPUT_STRIP_TRAILING_WHITESPACE<br>
>          )<br>
> <br>
> include_directories(${LLVM_INCLUDE_DIRS})<br>
> <br>
> set(helloworld_SRCS main.cpp)<br>
> add_executable(helloworld ${helloworld_SRCS})<br>
> target_link_libraries(helloworld<br>
>      Qt5::Widgets<br>
>      /usr/lib/llvm-13/lib/libclang.so<br>
>      /usr/lib/llvm-13/lib/libclang-cpp.so.13<br>
> )<br>
> ~<br>
> <br>
> <br>
> <br>
> On Tue, Apr 12, 2022 at 6:37 PM Milian Wolff <<a href="mailto:mail@milianw.de" target="_blank">mail@milianw.de</a> <br>
> <mailto:<a href="mailto:mail@milianw.de" target="_blank">mail@milianw.de</a>>> wrote:<br>
> <br>
>     On Tuesday, April 12, 2022 5:33:38 PM CEST Enes Albay wrote:<br>
>      > I found something. After removing clang and llvm from my system I<br>
>     get the<br>
>      > following error which is the same as before removing clang.<br>
>      ><br>
>      > I think the actual problem is clang_parseTranslationUnit2 can not<br>
>     call<br>
>      > clang even before removing clang<br>
>      ><br>
>      > Is there a way to verify such a situation?<br>
> <br>
>     We use libclang directly, not clang. Try to ldd on the<br>
>     kdevclangsupport or use<br>
>     gdb and `info shared` to see where it loads that from. You didn't<br>
>     remove all<br>
>     of that yet apparently.<br>
> <br>
>     -- <br>
>     Milian Wolff<br>
>     <a href="http://milianw.de" rel="noreferrer" target="_blank">http://milianw.de</a> <<a href="http://milianw.de" rel="noreferrer" target="_blank">http://milianw.de</a>><br>
> <br>
> <br>
> <br>
> <br>
> -- <br>
> Enes Albay<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div style="text-align:left">Enes Albay</div></div></div>