Use shared library with root

Hi Rooters,

I have been trying to use the C-version of the Naval Observatory Vector Astronomy Subroutines (NOVAS), mostly because it has a wrapper for the JPL Ephemeris fortran routines (yes, I need that much precision!). I can compile, link and create a shared library, and use this shared library with a compiled C++ program (main.c) The thing is, when I try to use the library in an ACLiC-compiled ROOT macro, it loads, but I get an undefined symbol error . I have attached a .tar.gz archive, which includes the library, the headers that need to be included, a macro called RunTestNovas.C that loads the library and loads the macro TestNovas.C. TestNovas.C has the function that I am trying to call from the library, julian_date. Thanks in advance!

-eric
root_talk.tar.gz (39.7 KB)

When using a C library from a C++ program you must specify, eg in your case

extern "C" { double julian_date (short int year, short int month, short int day, double hour); } i in your C++ file. Note that your example does not work without this specification when compiling TestNovas.C (as main) and libnovas.so.
The following version of TestNovas.C will work with the compiler and ACLIC

Rene

[code]#include <stdio.h>
extern “C” { double julian_date (short int year, short int month, short int day,
double hour);}

#include “novascon.h”
#include “novas.h”
#include “solarsystem.h”

using namespace std;

void TestNovas(){

double RA=0.;
double DEC = 0.;
double DIST = 0.;
double jul_date = julian_date(2007,8,3,8.0);

printf(“COOL! %f”,jul_date);
printf("\n");
}
[/code]