Emacs Rtags "ofMain.h file not found"

Hello!

Is anyone developping with emacs and managed to get autocompletion and flycheck working?
I have some autocompletion with rtags, but I still get “ofMain.h not found” and this completly blocks flycheck from working… I think flycheck can’t find “ofMain.h”.

Anyone has any experience with this?

Have you managed to make it work with other packages? Any advice is welcome!

Hi Dimitri,

I had no problems at all and just used bear to collect building information. See rtags setup

https://github.com/Andersbakken/rtags#setup

rdm has to run in the background. See the Quick start of rtags https://github.com/Andersbakken/rtags#tldr-quickstart

rdm &

or run rdm as a user service:

https://github.com/Andersbakken/rtags#integration-with-systemd-gnu-linux

On Ubuntu install bear with: sudo apt-get install bear

Then in your OF project - you can of course use an example project for testing -

bear make
rc -J .

In Emacs just install the rtags package with MELPA.

Hope it helps. Please let me know. Maybe you could provide some background on your OS.

Thank you for your reply!

I’m using Fedora 26, but I had this problem on Archlinux as well when I was using it.

I followed the rtags settings to the letter (using bear), and it works fine with other projects, I just never made it work with OF…
But my knowledge of emacs is very limited, so I’m probably doing something wrong^^

Have you made flycheck work as well in openframeworks?

Yes. It was also very easy. Flycheck also uses the compile_commands.json file and does a fantastic job. Rtags and Flycheck are actually the only solutions I could get working with OF. The indexer in CDT/Eclipse fails and the parser in KDevelop is just too slow to be usable.

The instructions are easy^^
I’ve made rtags work before. Also company. Also flycheck.
Just never together!

I’ve started a new configuration from scratch using the instructions, I’ve attached it for reference. Could you share your setup as well? So we can compare and see what I’m doing wrong^^

For reference, using Emacs 25.3.1

rtags-emacs-config.zip (1.2 KB)

Rtags works fine, I’ve had some autocompletion. But it doesn’t seem to be getting everything (for instance in the main.cpp file it can’t auto complet ofSetupOpengl).

Flycheck works fine on its on and other modes, but just shows nothing when rtags is around.

Hi Dimitri,

good you are asking. I am actually using rtags only for referencing and irony for completion. Regarding flycheck I use the irony-flycheck Emacs package. My init.el is a bit oldish and won’t probably help you. I would have to clean it up first as there are also security related settings in there. But here are the relevant entries of init.el I am using (Emacs 25.1.1):

(use-package flycheck
  :ensure t
  :init (global-flycheck-mode))

(require 'rtags)

(rtags-enable-standard-keybindings)

;; Irony mode
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

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

;; Irony Flycheck integration
(eval-after-load 'flycheck
  '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))

Here might be some interesting blog posts for you:

  1. https://oremacs.com/2017/03/28/emacs-cpp-ide/
  2. https://vxlabs.com/2016/04/11/step-by-step-guide-to-c-navigation-and-completion-with-emacs-and-the-clang-based-rtags/
  3. http://nilsdeppe.com/posts/emacs-c++-ide
  4. http://syamajala.github.io/c-ide.html

Actually, I used the first link as basis to setup my own configuration.

BTW, I have clang version 4.0.0 installed on my box. This might be also important.

I got it to work thank you!

I think I waslugging them all together incorrectly. And I shouldn’t have overlooked Irony, it looks super powerful!

Here’s a configuration I’ve managed to make to work for people that might be having the same issue.

rtags-emacs-config.zip (1.8 KB)

Thank you for your time!

I hope I could keep up your spirits while you were struggling with the configurations. :wink:

Thanks for sharing your config files. I will change mine to use more use-package in the future.

Half the fun is struggling :wink:
Yeah use-package is great, makes things more tidy!

I’d love to see what your configuration will look like then

hey schmidh & shadowmitia,

thanks a lot, this discussion was really helpful!