<div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Vladislav Martin</b> <span dir="ltr"><<a href="mailto:martin.vl@husky.neu.edu">martin.vl@husky.neu.edu</a>></span><br>Date: Wed, Jul 6, 2016 at 5:36 PM<br>Subject: Re: [gmx-developers] Compilation Errors When Using GROMACS Headers/Library<br>To: <a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br><br><br><div dir="ltr"><div><div><div>Mark,<br><br></div>Perfect! Now I feel silly - in all honesty, I never knew that "it is normal behaviour for installed headers intended for third-party
development to expect to have their path prepended by the preprocessor". Now that I know that, it is obvious that I simply needed to specify a directory to search for header files, by using the <a href="https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Preprocessor-Options.html#Preprocessor-Options" target="_blank"><font size="2"><span style="font-family:monospace,monospace">-I</span></font> option</a>.<span class=""><br><br>> Do also be aware that <span style="font-family:monospace,monospace">libxdrfile</span> is a thing.<br><br></span></div>I am aware of <span style="font-family:monospace,monospace">libxdrfile</span>, but as of yet I have yet to find enough documentation explaining it's use. The simple reason that I haven't used it is that I don't know how to use it. <br><br>So, I searched for other means that have already been implemented to read XTC trajectory files. After looking around the GROMACS 5.1.2 source code for references to XTC files, I was able to find the <span style="font-family:monospace,monospace">list_xtc(const char *fn)</span> function specified in the <span style="font-family:monospace,monospace">dump.c</span> source file located at <span style="font-family:monospace,monospace">src/gromacs/tools/dump.c</span>. I used the code that I found in this function to write the <span style="font-family:monospace,monospace">read_trajectory.c</span> file I was compiling.<br><br></div>Where might I find documentation that explains how I can use the <span style="font-family:monospace,monospace">libxdrfile</span> library to access all of the information that is accessed by the <span style="font-family:monospace,monospace">list_xtc</span> function? Also, why do you recommend this library over just using the GROMACS header files - does it allow for more efficient reading of the XTC files?<div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 6, 2016 at 5:06 PM, Mark Abraham <span dir="ltr"><<a href="mailto:mark.j.abraham@gmail.com" target="_blank">mark.j.abraham@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>It is normal behaviour for installed headers intended for third-party development to expect to have their path prepended by the preprocessor, e.g.</div><div><br></div><div><font face="monospace">gcc -I/usr/local/gromacs/include yourfile.c -L/usr/local/gromacs/lib/whatever -lgromacs</font></div><div><br></div><div>This means that the same header file can be used the same way when compiling libgromacs, so one gets some sanity for free. Otherwise, we'd also have to run some kind of script at "make install" time that copied the files and edited them, similar to what you have done with sed. Also, you'll have a harder time testing your code against multiple versions of GROMACS if you've hard-coded the path to the include files, perhaps in many places, directly in your code - the -I option is very much your friend.</div><div><br></div><div>Do also be aware that libxdrfile is a thing.</div><div><br></div><div>Mark</div></div><br><div class="gmail_quote"><div><div><div dir="ltr">On Wed, Jul 6, 2016 at 4:53 PM Vladislav Martin <<a href="mailto:martin.vl@husky.neu.edu" target="_blank">martin.vl@husky.neu.edu</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div><div><div><div>Dear GROMACS developers,<br><br></div>I am writing code in C utilizing the GROMACS 5.1.2 library. The purpose of the code is to read the binary data stored in GROMACS' XTC trajectory files into C data types for further analysis / manipulation of the data.<br><br></div><div>*NOTE*: In case this would be important information, I followed the <a href="http://manual.gromacs.org/documentation/5.1.2/install-guide/index.html#quick-and-dirty-installation" target="_blank">"Quick and Dirty Installation"</a> instructions for GROMACS 5.1.2 and all commands were executed in the terminal successfully.<br></div><div><br>Back to the C code. At the very top of my file, I include "/usr/local/gromacs/include/gromacs/fileio/xtcio.h" so that I may access the functions I need to read the XTC trajectory files. I ran into an odd error when attempting to compile my program. <br></div><br>""<br>$ gcc -o read_trajectory read_trajectory.c -L /usr/local/gromacs/lib/x86_64-linux-gnu/ -lgromacs<br>In file included from read_trajectory.c:3:0:<br>/usr/local/gromacs/include/gromacs/fileio/xtcio.h:41:35: fatal error: gromacs/fileio/gmxfio.h: No such file or directory<br> #include "gromacs/fileio/gmxfio.h"<br> ^<br>compilation terminated.<br>""<br><br></div>I can fix this error by running a bash command that searches recursively through all header files in the "usr/local/gromacs/include/gromacs" directory and replaces 'gromacs/' (which only shows up in #include statements) with '/usr/local/gromacs/include/gromacs/' (or '/path/to/your/installation/gromacs/include/gromacs/'). I have included this bash command in case someone else experiences this compilation error and wants to fix it quickly:<br><br>'""<br></div>$ sudo find /usr/local/gromacs/include/gromacs/ -name '*.h' -type f -exec sed -i 's:gromacs/:/usr/local/gromacs/include/gromacs/:' {} \;<br><div>""<br><br></div><div>Once I run this command, the program compiles successfully and I am able to run the resulting executable without any further errors.<br></div><div><br>What confuses me is that this error could have been fixed when the GROMACS header files were created in the first place - I shouldn't have to fix the relative paths where the header files are supposed to look for & find the other GROMACS header files. From what I can tell (I read the <a href="http://manual.gromacs.org/documentation/5.1.2/dev-manual/includestyle.html" target="_blank">#include directives</a>), every header file is contained within the "/usr/local/gromacs/include/gromacs/" directory (or, more generally, "/path/to/your/installation/gromacs/include/gromacs/"). Within that directory there are modular directories that store related headers, like "fileio/". Knowing all of this, why does an #include statement referring to a GROMACS header file in that <u>same</u> directory say "gromacs/fileio/gmxfio.h" - which, as a relative path, would <u>never</u> point to the right directory - instead of "gmxfio.h" or "./gmxfio.h", which actually reflects this file hierarchy?<br><br></div><div>In the end, my question is simple: did I miss something in the documentation that informs me on how to include GROMACS headers files properly so that I don't have to change the include statements myself? Otherwise, is this a syntax bug that will be fixed in later GROMACS versions?<br><br><br></div><div>Many thanks,<br><br></div><div>Vladislav Martin<br>Research Assistant<span style="font-weight:normal"></span><br>Center for Nanobiology and Structural Biology<br></div><div>Email: <a href="mailto:martin.vl@husky.neu.edu" target="_blank">martin.vl@husky.neu.edu</a><br></div></div></div></div><span><font color="#888888">
--<br>
Gromacs Developers mailing list<br>
<br>
* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a> before posting!<br>
<br>
* Can't post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists</a><br>
<br>
* For (un)subscribe requests visit<br>
<a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" target="_blank">gmx-developers-request@gromacs.org</a>.</font></span></blockquote></div>
<br>--<br>
Gromacs Developers mailing list<br>
<br>
* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a> before posting!<br>
<br>
* Can't post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists</a><br>
<br>
* For (un)subscribe requests visit<br>
<a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" target="_blank">gmx-developers-request@gromacs.org</a>.<br></blockquote></div><br></div></div></div></div>
</div><br></div>