Skip to content

kinship

3 messages · Andrew Beckerman, stefano iacus, Paul Roebuck

#
Dear all -

OS 10.4.2, R 2.2.0 + Tcltk and Fortran

I am trying to install the package "kinship", only available through  
source.  The package seems to do well until the very end, where a  
multiple definitions error crops up (see below).   A previous post  
and response from B. Ripley suggested the following:

"You need to change coxfit6.h to have the object extern in all but  
one of the files it is included in. That is a peculiarity of MacOS X."

Any advice on how to accomplish this?  Is it in the works with  
regards to packaging a binary?

Cheers
andrew

------------------
tar: Read 3584 bytes from -
* Installing *source* package 'kinship' ...
** libs
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c agfit6b.c -o  
agfit6b.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c  
bdsmatrix_index1.c -o bdsmatrix_index1.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c  
bdsmatrix_index2.c -o bdsmatrix_index2.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c  
bdsmatrix_index3.c -o bdsmatrix_index3.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c  
bdsmatrix_prod.c -o bdsmatrix_prod.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c  
bdsmatrix_prod2.c -o bdsmatrix_prod2.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c  
bdsmatrix_prod3.c -o bdsmatrix_prod3.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c chinv4.c -o  
chinv4.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c chinv5.c -o  
chinv5.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c cholesky4.c -o  
cholesky4.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c cholesky5.c -o  
cholesky5.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c chsolve4.c -o  
chsolve4.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c chsolve5.c -o  
chsolve5.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c coxfit6a.c -o  
coxfit6a.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c coxfit6b.c -o  
coxfit6b.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c coxfit6c.c -o  
coxfit6c.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c gchol.c -o  
gchol.o
gcc-3.3 -no-cpp-precomp -I/Library/Frameworks/R.framework/Resources/ 
include  -I/usr/local/include   -fno-common  -g -O2 -c gchol_bds.c -o  
gchol_bds.o

The downloaded packages are in
     /private/tmp/RtmpUlQDSt/downloaded_packages
gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/local/lib - 
o kinship.so agfit6b.o bdsmatrix_index1.o bdsmatrix_index2.o  
bdsmatrix_index3.o bdsmatrix_prod.o bdsmatrix_prod2.o  
bdsmatrix_prod3.o chinv4.o chinv5.o cholesky4.o cholesky5.o  
chsolve4.o chsolve5.o coxfit6a.o coxfit6b.o coxfit6c.o gchol.o  
gchol_bds.o  -lcc_dynamic -F/Library/Frameworks/R.framework/.. - 
framework R
** Removing '/Library/Frameworks/R.framework/Versions/2.2/Resources/ 
library/kinship'
ld: multiple definitions of symbol _c6
agfit6b.o definition of _c6 in section (__DATA,__common)
coxfit6a.o definition of _c6 in section (__DATA,__common)
coxfit6b.o definition of _c6 in section (__DATA,__common)
coxfit6c.o definition of _c6 in section (__DATA,__common)
ld: can't locate file for: -lcc_dynamic
make: *** [kinship.so] Error 1
ERROR: compilation failed for package 'kinship'

------------------------------------------------------------------------ 
---------
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.shef.ac.uk/beckslab
------------------------------------------------------------------------ 
----------
#
Andrew,
the problem is that in some headers you defines symbols used by  
different .c files.
You should define these extern everywhere but for on single .c file  
only.
One triky solution is to declare all of them as "extern" in the .h  
file and undef "extern" for one .c file only.
Have a look at R sources in files src/include/Defn.h and src/main/main.c

All symbols in Defn.h are defined as extern, and defn.h is included  
by many .c files.
Only main.c defines __MAIN__ which has the effect in Defn.h to  
undefine extern.

I've just helped mantainers of the latentnet package, they've got the  
same problem.

stefano
On 22/ott/05, at 12:12, Andrew Beckerman wrote:

            
#
On Sat, 22 Oct 2005, Andrew Beckerman wrote:

            
It's not exactly what I would call peculiar ("odd"); rather
it simply enforces that a given variable definition only
occurs once.
One approach might be to create a single file named
"foo_globals.h" (given project named "foo") with the
contents something like the following:

#ifndef FOO_GLOBALS_H
#define FOO_GLOBALS_H 1

#include <sys/types.h>

#ifdef DEFINE_GLOBALS
#define EXTERNALREF
#else
#define EXTERNALREF extern
#endif

/*
 * Global Variables
 */
EXTERNALREF unsigned gNumSims;

#endif /* FOO_GLOBALS_H */


All source files in your project that access the global variables
would #include "foo_globals.h" (possibly indirectly). For an
application, I would nominally have a minimal project header
(appropriately named "foo.h") which contained the following:

#ifndef FOO_H
#define FOO_H 1

#include "foo_types.h"   /* project-specific typedefs */
#include "foo_globals.h"

#endif /* FOO_H */


In the source file containing the main() function
(normally "foo.c"), you would prepend the preprocessor value
prior to including any project-specific headers.

#include <stdio.h>
#include <stdlib.h>
#define DEFINE_GLOBALS 1
#include "foo.h"

int main(int argc, char *argv[])
{
...
}

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)