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
Libclang can not find the builtin includes. #238
Comments
Can you rewrite the function like this: def getBuiltinHeaderPath(library_path):
path = library_path + "/../lib/clang"
try:
files = os.listdir(path)
except:
return None
files = sorted(files)
path = path + "/" + files[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
if canFindBuiltinHeaders(index, "/usr/lib/llvm")
return path
return None If this works, you may submit a pull request that adds this change to clang_complete. |
Hardcoding "lib" is not correct, on openSUSE 64bit the headers are in /usr/lib64/clang//include |
We don't hardcode here. We search at different (known) locations. Do you have a suggestion how we could do better? |
Ah sorry, I meant something like this
|
tobig. This function does not work. Because in line "files = os.listdir(path)" path not exist. |
What about this patch: tobiasgrosser@6cc2dd6 |
def getBuiltinHeaderPath(library_path):
know_paths = [library_path + "/../lib/clang", library_path + "/../lib64/clang", library_path + "/../clang"]
for path in know_paths:
try:
clang_path = os.listdir(path)
break
except :
pass
!!! Here do something if all path not exist
clang_path = sorted(clang_path)
path = path + "/" + clang_path[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
return None This code works for me. |
def getBuiltinHeaderPath(library_path):
path = library_path + "/../lib/clang"
try:
files = os.listdir(path)
files = sorted(files)
path = path + "/" + files[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
except:
pass
knownPaths = [
"/usr/lib/clang/3.2/include/", # Gentoo
"/usr/lib64/clang/include" # OpenSuse 64 bit
]
for path in knownPaths:
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
return None I some fix this patch. It's worked. |
I have gentoo 64bit and clang 3.2 |
@ulrich Thanks for testing. I added your changes to https://github.com/tobig/clang_complete/tree/known_builtin_headers . Does this branch now compile for you? If it does, I would like to submit as a pull request. |
This won't work on openSUSE because the correct path is clang version dependent, e.g /usr/lib64/clang/3.2/include so I suggest this code
|
def getBuiltinHeaderPath(library_path):
path = library_path + "/../lib/clang"
try:
files = os.listdir(path)
files = sorted(files)
path = path + "/" + files[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
except:
pass
knownPaths = [
"/usr/lib/clang", # Gentoo
"/usr/lib64/clang" # OpenSuse 64 bit
]
for path in knownPaths:
try:
files = os.listdir(path)
files = sorted(files)
path = path + "/" + files[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
except:
pass
return None This function correct for gentoo 64bit and will be correct for openSuse 64bit. |
Nice, can you open a pull request for this? |
Yes. |
Btw, it seems @cartman's version is a little denser. Do you see any benefit in the dublicated code in your version? |
Duplicate code is not very well. In function from @cartman need some fix. In the variable knownPaths must be added to " library_path + "/../clang" " |
I don't undestend, how this function be correct for openSuse. My value g:clang_library_path="/usr/lib/llvm" and "/usr/lib/clang/3.2/include".What a path libclang for the openSuse? |
@Urich Ah I missed that. If library_path is supposed to be path to path to libclang.so then the correct function would be like this: For example for 32bit library_path would be /usr/lib and for 64bit /usr/lib64
Anything I am missing here? |
def getBuiltinHeaderPath(library_path):
knownPaths = [
library_path + "/../lib/clang", # default value
library_path + "/../clang" # gentoo, opesuse
]
for path in knownPaths:
try:
files = os.listdir(path)
files = sorted(files)
path = path + "/" + files[-1] + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
except:
pass
return None I think the function should be something like that. |
If path library_path + "/clang" correct for opensuse then. knownPaths = [
library_path + "/../lib/clang", # default value
library_path + "/../clang" # gentoo
library_path + "/clang" # opesuse
] |
This whole function is unnecessarily complex imho, running clang to ask for library_path would be easier but yes library_path + "/clang" will work for openSUSE. |
HI, I tried to install the clang_complete on my machine(ubuntu 11.10), at the beginning I ran into the problem "libclang not found". I found that there was no libclang.so existing on my computer. so I just download the libclang.so, at the same time I installed llvm, then I put the libclang.so under the llvm folder. set g:clang_library_path='/usr/lib/llvm-2.9'. Then I ran into this "Libclang can not find the builtin includes" issue! Can anybody tell me what mistakes I made and what to do to fix it? I googled a lot can not find a solution. Thanks! |
@tashia, your problem is different. Please open a new bug, but I do remember that clang < 3.0 weren't supported anymore by clang_complete. |
Actually, @tashia seems to have the same problem. clang 2.9 should work. @tashia, where did you download libclang.so? Did you download it by itself? Normally you should have downloaded an entire archive that also contains a copy of clang for example. In this archive there should be a library directory included that contains files like "stdint.h". Do you have such files? |
I created the following pull request: #265 Could you verify it works for OpenSuse and Gentoo? |
Hey, I also get the message, that libclang can not find the builtin includes.
which I hoped to be correct, because /usr/lib/clang/3.3/include containts lots of headers (stddef.h for example). Edit: Seems like I also need to set g:clang_library_path. Then it works. |
Rudolf, did you check if #265 fixes the problem without requiring g:clang_library_path to be set? |
Hey, If I use the add_builtin_directories branch from tobig/clang_complete, it works without setting g:clang_user_options or g:clang_library_path. |
I get the same warning. Windows machine here. Just upgraded - to the current commit. It seems you've deprecated |
I am not looking for anything from gcc. libclang.dll should come itself with a directory of builtin includes. How did you install libclang.dll? Did you compile it from source? Can you look for a file called stddef.h in the llvm install directory: $ find llvm/install/ -name stddef.h This file comes with my LLVM installation. Do you have it? Where is it placed? |
Also, I am a little surpriced. Why is libclang.dll installed in a directory called 'bin'. I would have expected to find it |
Yes, I have compiled it from source. Indeed, on Windows it is located there, because
|
Can you try this branch: https://github.com/tobig/clang_complete/tree/debug_builtins and enable let g:clang_debug = 1 When starting vim (and typing :mess) you should see something like:
At least one of the clang commands should work. If non none references D:\Toolchains\x64\LLVM\3.3\lib\clang\3.3\include, then we need to figure out what is missing. I assume the directory separator is different in windows. Maybe you can figure out what exactly is wrong. |
Cool... What's going on? :)
|
My first guess would be as follows. It seems like clang_complete heavily relies on |
Yes, that could be the reason. Can you set clang_library_path to D:\Toolchains\x64\LLVM\3.3\bin? I currently don't have an idea how to get the library location automatically, in case it is already in the path. Is there a python function for this? |
So, bingo:
|
Can't you simply write something like |
Another way, probably more boilerplate, but works 100%, is to simply traverse all directories listed in |
On 02/20/2013 05:44 PM, Haroogan wrote:
I pushed another change. Can you look if it find the library? Tobi |
Well, I'd like to return to the issue since it is not resolved yet. Of course I don't get this warning anymore. However, That's why when I used
How is it supposed to work now? |
clang_complete does find the libraries using the normal clang driver. If clang++ and clang as compilers work correctly, clang_complete should also work. If clang++ and clang have issues finding such libraries, this is a clang bug that should be reported upstream. (You can also copy the old getopts scripts into clang_complete to work around this, but that would just be a workaround) |
The output now is:
Concerning the issue, do you have all std includes in clang distribution on linux? If yes, then you don't have problems with completing std, do you? What do you think can be done on Windows to alleviate this? I seems like |
On 02/20/2013 06:02 PM, Haroogan wrote:
Great. find_library works. I will write a proper patch at some point, but for now you can probably Regarding the std includes. On linux and mac os x the clang driver finds Cheers, |
For the record, I've just came across this page. Is that what you mean when referring to clang driver? Especially, this:
|
On 02/20/2013 06:12 PM, Haroogan wrote:
Yes, this page. But rather the information a little above. clang does diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp
I think this is really a problem with the clang driver that should be Tobias |
please add "/usr/local/lib/clang" into the search path. |
On Sat, 2013-04-27 at 01:15 -0700, egmkang wrote:
Could you create a patch and send a pull request? Tobi |
I am using a vim 32 bit compiled by @Haroogan, I am still having the pb referenced here... I filled a post in SO http://stackoverflow.com/questions/18801354/clang-complete-failed-with-libclang-message?noredirect=1#comment27727088_18801354 is there a description how to fix the issue ? |
This problem popped up for me after updating clang to 3.8.0, the The bug in the script is when defining
So, effectively, all I had to do was change the def getBuiltinHeaderPath(library_path):
if os.path.isfile(library_path):
library_path = os.path.dirname(library_path)
knownPaths = [
library_path + "/../lib/clang", # default value
library_path + "/../clang", # gentoo
library_path + "/clang", # opensuse
library_path + "/", # Google
"/usr/lib64/clang", # x86_64 (openSUSE, Fedora)
"/usr/lib/clang"
]
for path in knownPaths:
try:
files = os.listdir(path)
if len(files) >= 1:
files = sorted(files)
subDir = files[0]
else:
subDir = '.'
path = path + "/" + subDir + "/include/"
arg = "-I" + path
if canFindBuiltinHeaders(index, [arg]):
return path
except:
pass
return None I can't assume that the internal layout of the Anyways, this is what it took me, so makes sense to let everyone else know... I've just that feeling that a lot are having the same problem I |
@ dnery |
@AriaAsuka I made a pull-request with an equivalent solution. In my previous proposal I'm considering that there are no other subdirectories named after a version of clang; I noticed that simply reversing the ordering of the |
I solve this issue by following below steps. (CentOS -7)
root@localhost:~/.vim/plugin# ls knownPaths = [
#include using namespace std; int main() Hope this will help |
After open cpp file i did see message "WARNING: libclang can not find the builtin includes." etc. I did find wrong in function "getBuiltinHeaderPath". I did replace value path (library_path + "/../lib/clang") on this "library_path + "/../clang""
Value is library_path = /usr/lib/llvm
ps. Linux 3.3.8-gentoo
The text was updated successfully, but these errors were encountered: