On Mon, 2009-08-17 at 09:41 -0400, Kun Huang wrote:
> Hello everyone:
>
> Recently I am trying to use the xdr library downloaded from gromacs
> org to read xtc files. However when I link my program with the library
> there is an error. When I ran the make test, all the tests were
> passed. Thus I think that the library should work just I don't know
> how to link the program. I tried to read the makefile in the library
> but it is very
> complicated and beyond my scope. My program is very simple:
> //source file of cm.cc
> #include"/home/kun/xdr/include/xdrfile/xdrfile_xtc.h"
> g++ cm.o /home/kun/xdr/lib/libxdrfile.a there is a link error:
> cm.o: In function `main':
> cm.cc:(.text+0x2d): undefined reference to `read_xtc_natoms(char*,
> int*)'
> collect2: ld returned 1 exit status
> Could anyone help me?
This is the result of non-matching name spaces.
You're using C++, and xdrfile is written in C. Instead of
#include <xdrfile/xdrfile_xtc.h>
you need to use
extern C {
#include <xdrfile/xdrfile.h>
}
to get the name spaces correct.
--
------------------------------------------------------
Jussi Lehtola, FM, Tohtorikoulutettava
Fysiikan laitos, Helsingin Yliopisto
[email protected], p. 191 50632
------------------------------------------------------
Mr. Jussi Lehtola, M. Sc., Doctoral Student
Department of Physics, University of Helsinki, Finland
[email protected]
------------------------------------------------------
_______________________________________________
gmx-users mailing list [email protected]
http://lists.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 [email protected].
Can't post? Read http://www.gromacs.org/mailing_lists/users.php