Sublime Forum

Clang (C/C++/Objective-C/Objective-C++) autocomplete

#5

Only reason for the 65536 would be not being too familiar with the plugin api. Thanks for the fix and the visual marker changes :smile:

0 Likes

#6

Hey guys,

I wanted to give this plugin a try with ST2 (x86 version) on Windows 7 64-bits and plugin version 5c43973 (latest today).

I get the following python error:

Traceback (most recent call last): File ".\sublimeclang.py", line 190, in recompile File ".\clang\cindex.py", line 208, in location ValueError: Procedure called with not enough arguments (4 bytes missing) or wrong calling convention
I believe it has something to do with the communication between Clang and the python plugin, but since my python skills are quite weak, I’m not sure how to fix it.

Cheers

0 Likes

#7

Hmm. I get the same thing on my Windows installation, but nothing I tried seemed to fix it. I’m starting to think that the dll itself is broken, I used the precompiled 2.9 from the llvm website.

Is anyone using this plugin successfully on windows? If I get no replies I’ll just hack it to look like the following until someone can provide a proper fix:

    def location(self):
        import platform
        if platform.system() == "Windows":
            class hack:
                def __init__(self):
                    self.file = None
                    self.line = 0
                    self.column = 0
            return hack()

        return _clang_getDiagnosticLocation(self)
0 Likes

#8

FWIW, the hack seems to work on my machine as well. I’ll try to figure out why I still have include problems, though the -I parameter seems to point to the proper directory.

Thanks

0 Likes

#9

Great, thanks :smile:

I’m seeing a bit more of it working now. It does highlighting and stuff in my objective-C files. Unfortunately, it seems it still needs some flags set because clang is giving me some errors where there shouldn’t be. I’ll try to take a look and see if I can figure out what the problem is and maybe submit a patch or something.

[quote]
As for listing symbols that aren’t available, I only list the completions provided by clang + some filtering. If you have any suggestions for how to better filter or any options that should be provided to clang to suggest better completions, I’d be happy to change.[/quote]

Well, I just tried it again and I didn’t seem to notice the same behavior as before. But if it comes up again I’ll try to investigate a bit more.

0 Likes

#10

FYI just got a chance to test it on Linux and it’s not working there due to sublimetext.userecho.com/topic/8 … -in-linux/ so upvote that one if you’d like to see Linux support.

0 Likes

#11

Compiling libclang using Visual C++ was trivial so with the latest version in git getting the location of errors and warnings should be fine on Windows.

As for it not picking up your include paths, try modifying the user settings rather than the default settings. You can access those by ctrl+shift+P and typing “SublimeClang”.

0 Likes

#12

Regarding Linux errors

I’m running Ubuntu 11.10 64bit. I was able to get this plugin working by symlinking /usr/lib/python2.6/ to sublime2’s lib directory, and recompiling libclang.so to target a 64bit architecture.

1.) Install python2.6 via apt-get or synpactic.
2.) Backup python26.zip in sublime2’s lib directory (just for safe measure). I did mv “python26.zip backup.python26.zip”
3.) Symlink /usr/lib/python2.6/ to sublime2’s lib directory.
4.) Download and compile clang. (You can probably get away with installing clang from the ubuntu repos)
5.) Copy libclang.so from the installed location into /.config/sublime-text-2/Packages/SublimeClang/

I’m still left with the issue of Clang not being able to find “stdarg.h”, but I believe that’s a clang bug and has nothing to do with this plugin.

Note to the the author of this plugin: It’s probably best not to include the compiled library for linux in your repository, given that each architecture requires its own build. It may be a better idea just to have a text file instructing linux users to build and copy libclang themselves. Thanks for this awesome plugin!

0 Likes

#13

Thanks for the tip, I’ve deleted the default libclang.so and added your work around to the readme at github.com/quarnster/SublimeClang/.

0 Likes

#14

Hi, I tried installing SublimeClang on Windows 7 x64 (x64 sublime 2), however it did not work. During install through Package manager I get:

Reloading plugin C:\Users\radix\AppData\Roaming\Sublime Text 2\Packages\SublimeClang\sublimeclang.py
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 57, in reload_plugin
  File ".\sublimeclang.py", line 31, in <module>
    from clang import cindex
  File ".\clang\cindex.py", line 86, in <module>
    lib = get_cindex_library()
  File ".\clang\cindex.py", line 76, in get_cindex_library
    return cdll.LoadLibrary('libclang.dll')
  File ".\ctypes\__init__.py", line 431, in LoadLibrary
  File ".\ctypes\__init__.py", line 353, in __init__
WindowsError: [Error 193] %1 is not a valid Win32 application

Thanks.

0 Likes

#15

Until someone contributes a 64-bit libclang.dll, you’ll have to make do with using the 32 bit Sublime Text 2 if you want to use this plugin.

0 Likes

#16

Yeah I thought this was the case. I did manage to build libclang in 64 mode for windows. However, now I get these when it’s trying to autocomplete on -> or ::

Perhaps there’s an issue with how I built it…

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 175, in on_query_completions
  File ".\sublimeclang.py", line 596, in on_query_completions
  File ".\clang\cindex.py", line 1568, in codeComplete
WindowsError: exception: access violation writing 0x00000000000C0000
Traceback (most recent call last):
  File ".\sublimeclang.py", line 175, in worker
  File ".\clang\cindex.py", line 1546, in reparse
WindowsError: exception: access violation writing 0x0000000004EC0000

Here’s my libclang (x64, compiled using vc2010).
ttvd.org/temp/libclang_x64_vc2010.rar

Thanks!

0 Likes

#17

Are you working with huge files or is there any other reason you must use the 64-bit executable of Sublime Text 2?

0 Likes

#18

Hi,
I got it working on Arch Linux.
You have to add the header search path /usr/lib/clang/3.0/include to SublimeClang’s config. If your distribution doesn’t have clang 3.0 yet, you can find those headers in clang-3.0.src/lib/Headers of llvm.org/releases/3.0/clang-3.0.tar.gz

Thanks for your work, quarnster!

0 Likes

#19

Wow… this is utterly mind blowing even in its early state. My vote for best plugin…ever?

I would have killed for the equivalent of visual studio’s f12, and now i have it, plus really good code completion that just works (still a bit rough, but its great still)… props to you quarnster.

Edit: To help other newbies, to get the most out of it I had to change my options and add them to the User version of SublimeClang.sublime-settings like so: (on mac os lion, will try win 7 64 bit eventually)

"options":
	    
	        "-Wall",
	        "-std=c++11",
	        "-I/usr/lib/clang/3.0/include/",
	        "-I/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1",
	        "-I/Users/alanandersen/dev"
	    ]

Also, it seems once you install Xcode 4.2, all the gcc stuff is moved from /usr/ into /Developer, took a bit to figure that out…

0 Likes

#20

Cheers for the props guys :smile:

Please let me know if you have any specific requests or suggestions for making it better. Pull requests with new features are welcome.

0 Likes

#21

Hi, sorry for the newbyness but, on windows, how do you specify the include path ? It seems to never find my standard c includes.

[quote]Z:\local\pegasusmanager\LIBPEGASUSMANAGER_01_00_00\bins\fpgaconfig\fpgaconfig.c:15,10 - Fatal - ‘stdint.h’ file not found
Did you configure the include path used by clang properly?
See github.com/quarnster/SublimeClang for more details on how to configure SublimeClang.
[/quote]

Thanks a lot :smile:

0 Likes

#22

You need to open up the SublimeClang settings and tweak the “options” list by adding “-IC:/wherever/your/include/files/are”. A good start would be to search for stdint.h. Please let me know what path it resides in on your Windows installation and I’ll add it as a default path.

0 Likes

#23

No i do not work with large files, but I found that x64 version of sublime is faster on my machine than x32 for w/e reason. Do you have any suggestion as to what might be the problem with my x64 libclang ?

Thanks.

0 Likes

#24

No idea what the problem might be, but you could try this simple C++ sample and see if that works to isolate whether it’s your libclang.dll or something with the python bindings that’s broken. Please do let me know if you figure it out.

0 Likes