Thanks Jinhu!
That was indeed the problem! Sorry for not checking that more closely
before I posted. The problem was that I had the derived class library
listed before the base class library in the xxxAPP_LIB link list. That
was OK on Windows, but failing on Linux.
Everything works fine now.
Thanks,
Mark
> -----Original Message-----
> From: Song, Jinhu [mailto:[email protected]]
> Sent: Tuesday, April 29, 2008 11:17 AM
> To: Mark Rivers; [email protected]; [email protected]
> Cc: [email protected]
> Subject: RE: Beginners C++ questions
>
> Hi Mark,
>
> I had similar problem when I was trying to create a shared
> lib (not epics). It was fixed by checking the order of
> libraries to link.
>
> Hope this can give you a hint.
>
> Jinhu
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Mark Rivers
> Sent: Tuesday, April 29, 2008 8:23 AM
> To: [email protected]; [email protected]
> Cc: [email protected]
> Subject: FW: Beginners C++ questions
>
> Folks,
>
> I'm having a simple problem with linking C++ on Linux that I
> wonder if you can help with.
>
> Here's the problem.
>
> - I have a C++ base class and a number of derived classes.
> If the base class is in the same library as the derived
> classes everything is fine.
> However, if the base class is in a different library from the
> derived classes, then it compiles fine (because it finds the
> header file), but it fails at link time.
>
>
> My base class has methods like the following:
>
> /* Constructor */
> asynParamBase::asynParamBase(const char *portName, int maxAddr, int
> paramTableSize)
> : maxAddr(maxAddr){
>
>
> Since that is not declared static, if it were a C function
> the linker would find it even if it were in a different
> library. However, when I try to link this base class which
> is used by a derived class in another library I get the
> following error:
>
> ../NDPluginBase.cpp:454: undefined reference to
> `asynParamBase::asynParamBase[not-in-charge](char const*,
> int, int) '../../../lib/linux-x86//libADPlugin.a
> (NDPluginBase.o)(.text+0xfff): In function
> `NDPluginBase::NDPluginBase[in-charge](char const*, int, int,
> char const*, int, int, int)':
>
> However, if I force the linker to include the module that
> includes the base class source code by adding the following
> lines to the beginning of
> it:
>
> /* This is for testing */
> #include <epicsExport.h>
> int asynParamBaseDebug=0;
> epicsExportAddress(int, asynParamBaseDebug);
>
> and then add this line to the .dbd file:
>
> variable(asynParamBaseDebug,int)
>
> then it links OK.
>
> How do I get the linker to pull in the module with the base
> class definition without having to force it with that global
> definition?
>
> Andrew Johnson suggested putting the keyword epicsShareClass
> before the class definition. I tried that, but interestingly
> it links fine on Windows with or without that keyword, but
> fails on Linux with or without the keyword.
>
> Thanks,
> Mark
>
>
>
>
>
>
- References:
- RE: Beginners C++ questions Song, Jinhu
- Navigate by Date:
- Prev:
RE: Beginners C++ questions Song, Jinhu
- Next:
Re: RTEMS-GeSys_2.1.beta and cexp-1.5 for uC5282 Coldfire Module Till Straumann
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
<2008>
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: Beginners C++ questions Song, Jinhu
- Next:
snapCmp.pl for SaveRestore.tcl John Dobbins
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
<2008>
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|