[Rtk-users] Linker problem

Julien Jomier julien.jomier at kitware.com
Fri May 31 06:02:09 EDT 2013


Cyril,

You are missing the constructor definition and you should probably 
uncomment these lines:

//template <class TInputImage, class TOutputImage>
//PublicBackProjectionImageFilter<TInputImage,TOutputImage>
//::PublicBackProjectionImageFilter()
//{
//}

Julien

On 31/05/2013 11:14, MORY, CYRIL wrote:
> Hi Simon,
>
> Thanks for your answer. I think what I did is allowed in C++ (if I'm wrong, please correct me) : I have defined a daughter class with public methods that call protected methods of the mother class. I think it wouldn't be allowed, indeed, to change the private/protected/public type of a method, but that's not what I did. Just to check, I have tried to modify the two methods of the daughter class, removing the internal calls to the GetProjection() and GetIndexToIndexProjectionMatrix(). The linker error remains the same.
>
> I have the feeling it must be something obvious, but I can't find it. And I'd prefer not to copy-paste the code of these two functions. I'd give it another try today, and if it keeps not working I'll revert to the solution you propose.
>
> Regards,
> Cyril
>
> -----Message d'origine-----
> De : simon.rit at gmail.com [mailto:simon.rit at gmail.com] De la part de Simon Rit
> Envoyé : jeudi 30 mai 2013 18:07
> À : MORY, CYRIL
> Cc : rtk-users at openrtk.org
> Objet : Re: [Rtk-users] Linker problem
>
> Hi Cyril,
> I don't think it is allowed in C++ to change the private/protected/public type of a method in daughter classes.
> Otherwise, it would screw up the purpose of it. If your filter is not a BackProjection and you don't want to inherit from it, I would advise you to copy paste the GetIndexToIndexMatrix in your class. There are a few things there that depends on some class members so you will have to simplify it for your case (or have the same members in your class).
> Simon
>
>
> On Thu, May 30, 2013 at 5:48 PM, MORY, CYRIL <Cyril.Mory at philips.com> wrote:
>> Hi,
>>
>>
>>
>> I've written a small filter deriving from
>> rtk::BackProjectionImageFilter, because I needed to access the
>> protected methods GetProjection() and
>> GetIndexToIndexProjectionMatrix() for a CUDA filter I'm writing.
>>
>> The filter has only two additional methods, both public, called
>> PublicGetProjection() and PublicGetIndexToIndexProjectionMatrix(),
>> which call their protected counterparts.
>>
>> The .h and .txx files are below.
>>
>>
>>
>> When creating this filter in my CUDA filter, I get an error message
>> from the linker :
>>
>> ../../bin/librtkcuda.a(rtkCudaProjectionStackToFourDImageFilter.cxx.o)
>> : In function `rtk::PublicBackProjectionImageFilter<itk::Image<float,
>> 3u>, itk::Image<float, 3u> >::New()':
>>
>> /home/cyril/sources/rtk/RTK/code/rtkPublicBackProjectionImageFilter.h:57:
>> undefined reference to
>> `rtk::PublicBackProjectionImageFilter<itk::Image<float, 3u>,
>> itk::Image<float, 3u> >::PublicBackProjectionImageFilter()'
>>
>> collect2: error: ld returned 1 exit status
>>
>>
>>
>> It's probably a stupid mistake, but I can't find it. Can someone help me ?
>>
>>
>>
>> rtkPublicBackProjectionImageFilter.h
>>
>>
>>
>>
>>
>> #ifndef __rtkPublicBackProjectionImageFilter_h
>>
>> #define __rtkPublicBackProjectionImageFilter_h
>>
>>
>>
>> #include "rtkBackProjectionImageFilter.h"
>>
>>
>>
>> namespace rtk
>>
>> {
>>
>>
>>
>> /** \class PublicBackProjectionImageFilter
>>
>> * \brief BackProjectionImageFilter where protected methods are made
>> public
>>
>> *
>>
>> * This filter exposes some of the methods that are protected in
>> BackProjectionImageFilter
>>
>> * Required for CudaProjectionStackToFourDImageFilter
>>
>> *
>>
>> * \author Cyril Mory
>>
>> *
>>
>> * \ingroup Projector
>>
>> */
>>
>> template <class TInputImage, class TOutputImage>
>>
>> class ITK_EXPORT PublicBackProjectionImageFilter :
>>
>>          public
>> rtk::BackProjectionImageFilter<TInputImage,TOutputImage>
>>
>> {
>>
>> public:
>>
>>      /** Standard class typedefs. */
>>
>>      typedef PublicBackProjectionImageFilter                         Self;
>>
>>      typedef itk::ImageToImageFilter<TInputImage,TOutputImage>
>> Superclass;
>>
>>      typedef itk::SmartPointer<Self>                           Pointer;
>>
>>      typedef itk::SmartPointer<const Self>                     ConstPointer;
>>
>>      typedef typename TInputImage::PixelType InputPixelType;
>>
>>      typedef typename TOutputImage::RegionType OutputImageRegionType;
>>
>>
>>
>>      typedef rtk::ProjectionGeometry<TOutputImage::ImageDimension>
>> GeometryType;
>>
>>      typedef typename GeometryType::Pointer
>> GeometryPointer;
>>
>>      typedef typename GeometryType::MatrixType
>> ProjectionMatrixType;
>>
>>      typedef itk::Image<InputPixelType, TInputImage::ImageDimension-1>
>> ProjectionImageType;
>>
>>      typedef typename ProjectionImageType::Pointer
>> ProjectionImagePointer;
>>
>>
>>
>>      /** Method for creation through the object factory. */
>>
>>      itkNewMacro(Self)
>>
>>
>>
>>      /** Run-time type information (and related methods). */
>>
>>      itkTypeMacro(PublicBackProjectionImageFilter, BackProjectionImageFilter)
>>
>>
>>
>>      /** The input is a stack of projections, we need to interpolate in one
>> projection
>>
>>        for efficiency during interpolation. Use of itk::ExtractImageFilter is
>>
>>        not threadsafe in ThreadedGenerateData, this one is. The output can be
>> multiplied by a constant. */
>>
>>      ProjectionImagePointer PublicGetProjection(const unsigned int iProj);
>>
>>
>>
>>      /** Creates iProj index to index projection matrices with current inputs
>>
>>        instead of the physical point to physical point projection matrix
>> provided by Geometry */
>>
>>      ProjectionMatrixType PublicGetIndexToIndexProjectionMatrix(const
>> unsigned int iProj);
>>
>> protected:
>>
>>      PublicBackProjectionImageFilter();
>>
>>      virtual ~PublicBackProjectionImageFilter() {}
>>
>>
>>
>> private:
>>
>>      PublicBackProjectionImageFilter(const Self&); //purposely not
>> implemented
>>
>>      void operator=(const Self&);            //purposely not implemented
>>
>>
>>
>> };
>>
>>
>>
>> } // end namespace rtk
>>
>>
>>
>> #ifndef ITK_MANUAL_INSTANTIATION
>>
>> #include "rtkPublicBackProjectionImageFilter.txx"
>>
>> #endif
>>
>>
>>
>> #endif
>>
>>
>>
>>
>>
>>
>>
>> rtkPublicBackProjectionImageFilter.txx
>>
>>
>>
>> /*=========================================================================
>>
>> *
>>
>> *  Copyright RTK Consortium
>>
>> *
>>
>> *  Licensed under the Apache License, Version 2.0 (the "License");
>>
>> *  you may not use this file except in compliance with the License.
>>
>> *  You may obtain a copy of the License at
>>
>> *
>>
>> *         http://www.apache.org/licenses/LICENSE-2.0.txt
>>
>> *
>>
>> *  Unless required by applicable law or agreed to in writing, software
>>
>> *  distributed under the License is distributed on an "AS IS" BASIS,
>>
>> *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>>
>> *  See the License for the specific language governing permissions and
>>
>> *  limitations under the License.
>>
>> *
>>
>> *=========================================================================*/
>>
>>
>>
>> #ifndef __rtkPublicBackProjectionImageFilter_txx
>>
>> #define __rtkPublicBackProjectionImageFilter_txx
>>
>>
>>
>> #include "rtkPublicBackProjectionImageFilter.h"
>>
>>
>>
>> namespace rtk
>>
>> {
>>
>>
>>
>> //template <class TInputImage, class TOutputImage>
>>
>> //PublicBackProjectionImageFilter<TInputImage,TOutputImage>
>>
>> //::PublicBackProjectionImageFilter()
>>
>> //{
>>
>> //}
>>
>>
>>
>> template <class TInputImage, class TOutputImage>
>>
>> typename
>> PublicBackProjectionImageFilter<TInputImage,TOutputImage>::ProjectionImagePointer
>>
>> PublicBackProjectionImageFilter<TInputImage,TOutputImage>
>>
>> ::PublicGetProjection(const unsigned int iProj)
>>
>> {
>>
>>      return this->GetProjection(iProj);
>>
>> }
>>
>>
>>
>> template <class TInputImage, class TOutputImage>
>>
>> typename
>> PublicBackProjectionImageFilter<TInputImage,TOutputImage>::ProjectionMatrixType
>>
>> PublicBackProjectionImageFilter<TInputImage,TOutputImage>
>>
>> ::PublicGetIndexToIndexProjectionMatrix(const unsigned int iProj)
>>
>> {
>>
>>      return this->GetIndexToIndexProjectionMatrix(iProj);
>>
>> }
>>
>>
>>
>> } // end namespace rtk
>>
>>
>>
>> #endif
>>
>>
>> ________________________________
>> The information contained in this message may be confidential and legally
>> protected under applicable law. The message is intended solely for the
>> addressee(s). If you are not the intended recipient, you are hereby notified
>> that any use, forwarding, dissemination, or reproduction of this message is
>> strictly prohibited and may be unlawful. If you are not the intended
>> recipient, please contact the sender by return e-mail and destroy all copies
>> of the original message.
>>
>> _______________________________________________
>> Rtk-users mailing list
>> Rtk-users at openrtk.org
>> http://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users
>>
>
> ________________________________
> The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
>
> _______________________________________________
> Rtk-users mailing list
> Rtk-users at openrtk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users
>



More information about the Rtk-users mailing list