You cannot expect gcc (the C compiler) to link C++ compiled code.
Use g++, or work out what additional libraries you need.
(R uses MinGW and links with g++, so that is a tested route.)
On Sun, 23 May 2004, Yingfu Xie wrote:
> Hello, all,
>
> I am learning to use the Connect/C++ class library via .Call(). I know how
> to compile and build a DLL for ordinary C code with .Call, as introduced in
> S-programming, using MinGW gcc compiler. But when I came to the example
> GaussSeidel (Programmer's Guide, p696), problem arose. I don't know if there
> are any other tricks, or I can follow the same procedure, namely,
> gcc -x c++ -c -mrtd -Idirectory myfile.c
> gcc -shared -o S.dll myfile.o -L"%S_HOME%/lib/mingw" -lSqpe
>
> I attached the more detailed error messages below. Can any kind soul help
> me? I really appreciate any comments and helps.
>
> All the best,
>
> Yingfu
>
> Problem description:
>
> All the error message in the first compiling step, mainly with file
> spalcfrm.h:
>
> D:\s-project\Classification\sconnect>gcc -Wall -x c++ -c -mrtd -I"c:\program
> files\insightful\splus62\sconnect" -I"c:\program
> files\insightful\splus62\include" -I"c:\program
> files\insightful\splus62\samples\GaussSDL" gaussdl.c
>
> In file included from c:/program
> files/insightful/splus62/sconnect/spvector.h:18
> ,
> from c:/program
> files/insightful/splus62/sconnect/spchar.h:16,
> from c:/program
> files/insightful/splus62/sconnect/sconnect.h:15
> ,
> from gaussdl.c:2:
> c:/program files/insightful/splus62/sconnect/spalcfrm.h:33: warning:
> `dllimport' attribute ignored
> c:/program files/insightful/splus62/sconnect/spalcfrm.h:33: declaration does
> not declare anything
> c:/program files/insightful/splus62/sconnect/spalcfrm.h:33: parse error
> before `)' token
> c:/program files/insightful/splus62/sconnect/spalcfrm.h:34: parse error
> before `long'
>
> I don't know what is wrong. However, if I temporarily comment out the
> concerned file spalcfrm.h, the first step is ok. But then, when I proceed to
> the second with the next command line, many 'undefined reference' errors
> occurred, most like the last two.
>
> D:\s-project\Classification\sconnect>gcc -shared -o S.dll gaussdl.o
> -L"c:\program files\insightful\splus62\lib\mingw" -lSqpe
>
> gaussdl.o(.text+0x58):gaussdl.c: undefined reference to
> `__gxx_personality_sj0'
> gaussdl.o(.text+0xba):gaussdl.c: undefined reference to
> `CSPnumericMatrix::CSPnumericMatrix(s_object_struct*, int)'
>
> Thank you for your time!
> ###########################################
>
> This message has been scanned by F-Secure
> Anti-Virus for Microsoft Exchange.
>
> ###########################################
>
>
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
>
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|