[gmx-users] How to compile C++ propgram with xdrfile library?

Semen Esilevsky yesint4 at yahoo.com
Sun May 17 19:56:28 CEST 2009


Ok, I have found the bug.
In file xdrfile_xtc.h conditional directives should be "#ifdef __cplusplus", not "#ifdef CPLUSPLUS" !




----- Original Message ----
From: Semen Esilevsky <yesint4 at yahoo.com>
To: Discussion list for GROMACS users <gmx-users at gromacs.org>
Sent: Sunday, May 17, 2009 8:47:44 PM
Subject: Re: [gmx-users] How to compile C++ propgram with xdrfile library?


Well, it seems that changing all bools to ints doesn't help. It still work with C but not with C++.
I changed bools to ints  and recompiled the library.
Then I copied xdrfile_c_test.c, headers and the recompiled library to the separate directory.

gcc -c  xdrfile_c_test.c
gcc  xdrfile_c_test.o  libxdrfile.a -lm

After that I have functional text program. 
Now, I tried to make a test with C++ with this simplest program:


#include "xdrfile.h"
#include "xdrfile_xtc.h"
int main(){
XDRFILE* xd = xdrfile_open("a.xtc","r");
int n;
read_xtc_natoms("a.xtc",&n);
}

g++  -c test.cpp    //Works fine
g++  test.o  libxdrfile.a

test.o: In function `main':
test.cpp:(.text+0x38): undefined reference to `read_xtc_natoms(char*, int*)'
collect2: ld returned 1 exit status


I'm completely and absolutely lost now... Any ideas?




----- Original Message ----
From: David van der Spoel <spoel at xray.bmc.uu.se>
To: Discussion list for GROMACS users <gmx-users at gromacs.org>
Sent: Sunday, May 17, 2009 4:05:16 PM
Subject: Re: [gmx-users] How to compile C++ propgram with xdrfile library?

Semen Esilevsky wrote:
> Ok, I've submitted a bug report. Concerning changing bools to ints. Where should I do this?
> 
In the libdrfile source code.
> 
> 
> ----- Original Message ----
> From: David van der Spoel <spoel at xray.bmc.uu.se>
> To: Discussion list for GROMACS users <gmx-users at gromacs.org>
> Sent: Sunday, May 17, 2009 2:57:36 PM
> Subject: Re: [gmx-users] How to compile C++ propgram with xdrfile library?
> 
> Semen Esilevsky wrote:
>> Dear All,
>> I'm trying to add the functionality of reading xtc to my own C++ code for a long time, so I was looking forward for libxdrfile release. Finally it is released and I tried it. I included xdrfile_xtc.h and immediately got the following error:
>> 
>> /usr/local/gentop/include/xdrfile/xdrfile.h|112|error: redeclaration of C++ built-in type ‘bool’|
>> 
>> This error is inside "#ifdef __cplusplus" block, so I presume that it should work with C++ compiler, but it does not...
>> I'm not proficient in C/C++ issues, so I have no idea what should I do to make it work with g++ compiler.
>> Any help is deeply appreciated!
> 
> Please file a bug report and I will fix it a bit later.
> 
> A simple solution is also to replace all bools by int.
>> Regards,
>> Semen
>> 
>> 
>> 
>>       _______________________________________________
>> gmx-users mailing list    gmx-users at gromacs.org
>> http://www.gromacs.org/mailman/listinfo/gmx-users
>> Please search the archive at http://www.gromacs.org/search before posting!
>> Please don't post (un)subscribe requests to the list. Use the www interface or send it to gmx-users-request at gromacs.org.
>> Can't post? Read http://www.gromacs.org/mailing_lists/users.php
> 
> 
> -- David van der Spoel, Ph.D., Professor of Biology
> Molec. Biophys. group, Dept. of Cell & Molec. Biol., Uppsala University.
> Box 596, 75124 Uppsala, Sweden. Phone:    +46184714205. Fax: +4618511755.
> spoel at xray.bmc.uu.se    spoel at gromacs.org   http://folding.bmc.uu.se
> _______________________________________________
> gmx-users mailing list    gmx-users at gromacs.org
> http://www.gromacs.org/mailman/listinfo/gmx-users
> Please search the archive at http://www.gromacs.org/search before posting!
> Please don't post (un)subscribe requests to the list. Use the www interface or send it to gmx-users-request at gromacs.org.
> Can't post? Read http://www.gromacs.org/mailing_lists/users.php
> 
> 
> 
>       _______________________________________________
> gmx-users mailing list    gmx-users at gromacs.org
> http://www.gromacs.org/mailman/listinfo/gmx-users
> Please search the archive at http://www.gromacs.org/search before posting!
> Please don't post (un)subscribe requests to the list. Use the www interface or send it to gmx-users-request at gromacs.org.
> Can't post? Read http://www.gromacs.org/mailing_lists/users.php


-- David van der Spoel, Ph.D., Professor of Biology
Molec. Biophys. group, Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone:    +46184714205. Fax: +4618511755.
spoel at xray.bmc.uu.se    spoel at gromacs.org  http://folding.bmc.uu.se
_______________________________________________
gmx-users mailing list    gmx-users at gromacs.org
http://www.gromacs.org/mailman/listinfo/gmx-users
Please search the archive at http://www.gromacs.org/search before posting!
Please don't post (un)subscribe requests to the list. Use the www interface or send it to gmx-users-request at gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php



  
_______________________________________________
gmx-users mailing list    gmx-users at gromacs.org
http://www.gromacs.org/mailman/listinfo/gmx-users
Please search the archive at http://www.gromacs.org/search before posting!
Please don't post (un)subscribe requests to the list. Use the
www interface or send it to gmx-users-request at gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php



      



More information about the gromacs.org_gmx-users mailing list