erlide_eclipse
erlide_eclipse copied to clipboard
Need assistance in using -include and -include_lib
Trying to do Erlang development with the RabbitMQ Erlang Client. To do that requires including header files:
-include("amqp_client.hrl").
(http://www.rabbitmq.com/erlang-client-user-guide.html#headers) and, of course, THAT file contains some include_lib statements:
-include_lib("rabbit_common/include/rabbit.hrl"). -include_lib("rabbit_common/include/rabbit_framing.hrl").
Now I have tried adding a relative path to the location of the amqp_client.hrl file via Windows > Preferences > Erlang > Compiler in the "Additional include dirs:" field, but the compiler still complains it can'f find the file.
I tried right-click on my Erlang project, clicking on Properties and then Erlang, but when I click on the include field's New... button, it only presents me with folders specifically in that Erlang Project. I had tried adding references of this project to a project I had downloaded from the RabbitMQ's Mercurial repository (built the code from a terminal window and then refreshed the project in Eclipse), but it wouldn't appear in the list presented by the New... button.
Basically I have to be missing SOMETHING, but every "solution" I have found related to ERLIDE and -include/-include_lib hasn't helped this "blind man" exclaim, "I see!".
Now in return if I CAN get this to work, I will GLADLY provide images, etc. for review/approval as an addition to the Wiki. 8^D
Jay
PS: I would gladly discuss this off-line or in some forum, if you'll provide me with where to go for that (say the Eclipse forums as an example).
SLAP! I >> THINK << I just figured out how to do it, but want someone to double-check it.
Give the following:
The header files I need I have located in my account's Documents/rabbitmq-public-umbrella/rabbitmq-erlang-client folder
- Right-click my project and choose Import...
- Twirl down General, select File System, and click Next
- Browse to the rabbitmq-erlang-client folder to identify the From directory
- Twirl down the rabbitmq-erlang-client and check the include folder in the left-hand pane.
- Uncheck all but the amqp_client.hrl file in the right-hand pane. I had clicked on the Advanced>> button, but made no changes other than checking the "create top-level folder" (see below).
- Click Finish
Now to specify the Include directory:
- Right-click my project and choose Properties
- Under "Include directories:" click on the New... button
- Twirl down my project's folder, twirl down the rabbitmq-erlang-client folder, click on the include folder (highlights it), and click OK to close that dialog and then OK again to close the Project Properties dialog.
My project now has a new folder in it, called rabbitmq-erlang-client, which has one folder in it, called include, which contains one file names amqp_client.hrl.
Now when I build my project it happily compiles and runs without a hitch.
Jay
BTW: I came back and edited step 5. When I reran the same steps a second time (to double-check them) I did NOT have the "create top-level folder" checked. That imported the file (link) directly into the include folder and so I didn't need to do the steps for specifying an include directory.
Hi Jay, the procedure you described is a little overcomplicated, but has the advantage that you can navigate to the rabbit-mq code. If you don't need that or look for a simpler solution, read on.
When you think about it, -include_lib depends on a global setting, the code path of the node doing the compilation. another way to make it recognize your libraries is to add them to the code path of the backend. This can be done by opening the runtime properties (window→ preferences→ erlang→ installed runtimes→ edit) and adding in the "extra args" field something like "-pa /path/to/rabbit-mq/ebin". If RabbitMQ is structured as an OTP application, then the includes will be found by -include_lib.
[The runtime preferences dialog has an explicit code path field, but it is disabled at the moment]
Soon™, we will add support for defining external libraries and then their source code can be navigated just like the OTP sources.
So save to think that following the "overcomplicated" procedure would prove helpful since I will need ready access to the "bowels" of RabbitMQ (debugger, tracing, etc.)?
Yes, your solution works. It's just that the users should not have to do all this manually.
The right way to do this would be to either have a separate project for rabbitmq and refer to it from your application (when you want to even build rabbitmq) or to define a library reference to rabbitmq (when you're only after the includes). We have already this planned for as an upcoming feature (but no time plan).