I‘ve download the “LLVM source code (.sig)” and “Clang source code (.sig)” and build Clang on Windows/MinGW. After that, I’ve install emacs (25.1) and the following three packages from melpa:

  • irony
  • company
  • company-irony

My init.el file configuration is the next (nothing else):

(require 'package)

(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))

(package-initialize)


(add-hook 'after-init-hook 'global-company-mode)

(eval-after-load 'company
  '(add-to-list 'company-backends 'company-irony))


(add-hook 'c++-mode-hook 'irony-mode)

(add-hook 'c-mode-hook 'irony-mode)

(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)

(define-key irony-mode-map [remap complete-symbol]
    'irony-completion-at-point-async))

(add-hook 'irony-mode-hook 'my-irony-mode-hook)

(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

(when (boundp 'w32-pipe-read-delay)
  (setq w32-pipe-read-delay 0))

(when (boundp 'w32-pipe-buffer-size)
  (setq irony-server-w32-pipe-buffer-size (* 64 1024)))

After that, I proceed to compile the Irony-server, with these steps:

  1. cd to Irony’s package site.

    D:\hh_home\.emacs.d\elpa\irony-20171002.1130\server

  2. create build directory.

    mkdir build && cd build

  3. compile with cmake(cmake-3.9.4-win64-x64) typing in cmd these three commands

    • cmake -DLIBCLANG_LIBRARY=D:\tt_tools\LLVM\5_0_0\llvm\bin\libclang.dll -G "MinGW Makefiles" ..

    • mingw32-make

    • "cmake" "-DCMAKE_INSTALL_PREFIX=d:/hh_home/.emacs.d/irony/" "d:/hh_home/.emacs.d/elpa/irony-20171002.1130/server" && "cmake" --build . --use-stderr --config Release --target install

Everything seems OK at this point. I checked that the Cmake placed irony-server.exe in the specified folder.

After that, I run emacs with simple hello.cpp file (at source path D:) and check emacs starts company-mode and irony-mode but irony-server.exe is not running.

Just when I type M-x company-irony is when irony-server.exe starts but doesn’t show anything related apparently with the completion at point that should be and seems that company-irony is deactivated (or switched to another ?) with company-mode and irony-mode active.

Additionally checking other completion tests, i.e: std::vector vec; vec. ¿? doesn’t show anything and when I type M-x company-mode at completion point the buffer says “Cannot complete at point”.

To specify the compilation flags and the system header locations I’m using the following .clang_format file in D:\

-std=c++14 

-target
x86_64-w64-mingw32

-Wall

-pedantic

-DDEBUG

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../include/c++/7.2.0

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../include/c++/7.2.0/bits

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../include/c++/7.2.0/x86_64-w64-mingw32

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../include/c++/7.2.0/backward

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/include

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed

-ID:\tt_tools\mingw\distro\15_3\bin\../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/include

I’ve obtained the location of my paths typing cpp -xc++ -Wp,-v < NUL and copying literally from …search stars here. By the way: gcc version 7.2.0 (GCC), Target: x86_64-w64-mingw32 and Thread model: posix.

I’ve made a lot of test to try to enable this feature but nothing… :-( Hope someone can help me litle bit…

Many thanks

I found that my emacs exec_path was not properly configured. After fixed that issue, I have checked with irony-mode activated, at completion point, company-irony is automatically activated in the mode line. All the local completions that I have made shows the correct completion options even system headers with the proper .clang_complete file. Now I have this great tool in my configuration to start to work with it.

  • Please explain the exec_path problem and your fix for it. This answer doesn't really help others, I'm afraid. If you think there's something in the question and the answer than can be helpful, please edit the answer (and perhaps the question) to make the message clear. Otherwise, please delete the question and answer. An unclear problem statement and an unclear (missing) solution description are not very helpful. – Drew Dec 11 '17 at 1:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.