Sublime Forum

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

#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

#25

Well the file is there : c:\MinGW\include

And none of those work:

    "options":
    
        "-Wall",
        "-I/C/MinGW/include",
        "-IC/MinGW/include",
        "-IC:/MinGW/include"
    ]
0 Likes

#26

Actually, looks like you’ve found a bug in Sublime Text.

Please upgrade the plugin to the latest version just submitted that has a fix for this or move the options to your SublimeClang user settings. “-IC:/MinGW/include” should work just fine and is now added to the default include paths. Please let me know if this fixes the issue or if you’re still having problems. Thanks.

0 Likes

#27

BTW, you probably want to edit the SublimeClang user settings anyway as the default settings might be overwritten when the plugin is updated.

0 Likes

#28

It works thanks.

I’ll edit my user settings as you suggested.

0 Likes

#29

This is awesome. Love this. I’ve gotten a fairly complex C++ project, and most things are now working for me.

One thing that doesn’t seem to work for me, is the ctrl-d ctrl-i to jump to the definition. It displays “Don’t know where the implementation is!” on the sublime status line. I’ve peeked at the Python code for the error, but not sure where the problem is or how to debug the python.

I’ve tried with a simple test: myutil.h and myutil.c that exist in the same directory. I’ve also made sure that I’ve got a -I to the same directory that holds myutil.h in the SublimeClang.sublime-settings file. I’m on Mac OS X Lion.

.c file is like:
#include <myutil.h>

int myFunc(int a, int b, double c) {
return a + b;
}

and .h file just has:
int myFunc(int a, int b, double c);

Any ideas?

Thanks again for the excellent work!

0 Likes

#30

Try updating the plugin now, it should be fixed in the latest version in git.

Thanks for reporting this and please let me know if it now works or if it’s still broken :smile:

0 Likes

#31

That fixed it, thanks for the fast turn around.

0 Likes

#32

Is there a way to configure this to autocomplete OS X and iOS frameworks and autocomplete Objective-C properly?

Unfortunately I can’t get the frameworks to autocomplete just by adding an include path since Framework’s are structured Name.framework/Headers/.h
But they are included as <Name/file.h>.

0 Likes