Hi, Does anyone know how to compile C++ code that uses 3rd party C++ libraries, so that the .so file can be used in R? I keep getting errors when using dyn.load which say undefined reference to KdSpiltRule, which is in my third party library. Here is the entire code...... // Computes a rapid Gamma test using ANN (Approximate Near Neighbour) library #include <stdio.h> // C I/O #include <string.h> // string manipulation #include <math.h> // math routines #include "/home/sekemp/ann_0.2/include/ANN/ANN.h" // ANN declarations extern "C" { void rapidGammaTest(double *inputs, double *outputs, int *dim, int *n_pts, int *k, double *sum) { ANNpointArray data_pts; // data points ANNpoint query_pt; // query point ANNidxArray nn_idx; // near neighbor indices ANNdistArray dists; // near neighbor distances ANNkd_tree *the_tree; // search structure query_pt = annAllocPt(*dim); // allocate query point data_pts = annAllocPts(*n_pts, *dim); // allocate data points nn_idx = new ANNidx[*k]; // allocate near neigh indices dists = new ANNdist[*k]; // allocate near neighbor dists int inc = 0; for(int i = 0; i < *n_pts; i++) { ANNpoint p; for(int j = 0; j < *dim; j++) { p[j] = inputs[inc]; inc++; } data_pts[i] = p; } int bs = 32; int M = *n_pts; int n_NN = *k; the_tree = new ANNkd_tree( // build search structure data_pts, // the data points M, // number of points n_NN, // dimension of space bs); // bucket size for(int t = 0; t < n_NN; t++) { sum[t] = 0.00; } for(int j = 0; j < M; j++) { the_tree->annkSearch( // search data_pts[j], // query point n_NN, // number of near neighbors nn_idx, // nearest neighbors (returned) dists); // distance (returned) for (int g = 0; g < n_NN; g++) { sum[g] += pow(sqrt(dists[g]), 2); } } } }