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

2009-05-17 Thread Jussi Lehtola
On Sun, 2009-05-17 at 10:56 -0700, Semen Esilevsky wrote:
> Ok, I have found the bug.
> In file xdrfile_xtc.h conditional directives should be "#ifdef __cplusplus", 
> not "#ifdef CPLUSPLUS" !



> 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);
> }


That, or you can just use

extern C {
#include "xdrfile.h"
#include "xdrfile_xtc.h"
}

int main()
and so on

The same thing also works for gromacs header files.
-- 
--
Jussi Lehtola, FM, Tohtorikoulutettava
Fysiikan laitos, Helsingin Yliopisto
jussi.leht...@helsinki.fi, p. 191 50632
--
Mr. Jussi Lehtola, M. Sc., Doctoral Student
Department of Physics, University of Helsinki, Finland
jussi.leht...@helsinki.fi
--


___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php


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

2009-05-17 Thread Semen Esilevsky

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 
To: Discussion list for GROMACS users 
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 
To: Discussion list for GROMACS users 
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 
> To: Discussion list for GROMACS users 
> 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 listgmx-users@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-requ...@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.
> sp...@xray.bmc.uu.sesp...@gromacs.org   http://folding.bmc.uu.se
> ___
> gmx-users mailing listgmx-users@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-requ...@gromacs.org.
> Can't post? Read http://www.gromacs.org/mailing_lists/users.php
> 
> 
> 
>   ___
> gmx-users mailing listgmx-users@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-requ...@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.
sp...@xray.bmc.uu.sesp...@gromacs.org  http://folding.bmc.uu.se
___
gmx-users mailing listgmx-users@gromacs.org
http://www.gromacs.org/mailman/listinfo

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

2009-05-17 Thread Semen Esilevsky

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 
To: Discussion list for GROMACS users 
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 
> To: Discussion list for GROMACS users 
> 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 listgmx-users@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-requ...@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.
> sp...@xray.bmc.uu.sesp...@gromacs.org   http://folding.bmc.uu.se
> ___
> gmx-users mailing listgmx-users@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-requ...@gromacs.org.
> Can't post? Read http://www.gromacs.org/mailing_lists/users.php
> 
> 
> 
>   ___
> gmx-users mailing listgmx-users@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-requ...@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.
sp...@xray.bmc.uu.sesp...@gromacs.org  http://folding.bmc.uu.se
___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php



  
___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php


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

2009-05-17 Thread David van der Spoel

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 
To: Discussion list for GROMACS users 
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 listgmx-users@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-requ...@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.
sp...@xray.bmc.uu.sesp...@gromacs.org   http://folding.bmc.uu.se
___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php



  
___

gmx-users mailing listgmx-users@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-requ...@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.
sp...@xray.bmc.uu.sesp...@gromacs.org   http://folding.bmc.uu.se
___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.

Can't post? Read http://www.gromacs.org/mailing_lists/users.php


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

2009-05-17 Thread Semen Esilevsky

Ok, I've submitted a bug report. Concerning changing bools to ints. Where 
should I do this?



- Original Message 
From: David van der Spoel 
To: Discussion list for GROMACS users 
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 listgmx-users@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-requ...@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.
sp...@xray.bmc.uu.sesp...@gromacs.org   http://folding.bmc.uu.se
___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php




___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.
Can't post? Read http://www.gromacs.org/mailing_lists/users.php


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

2009-05-17 Thread David van der Spoel

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 listgmx-users@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-requ...@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.
sp...@xray.bmc.uu.sesp...@gromacs.org   http://folding.bmc.uu.se
___
gmx-users mailing listgmx-users@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-requ...@gromacs.org.

Can't post? Read http://www.gromacs.org/mailing_lists/users.php