[vtkusers] vtkStandardNewMacro problems with MSVC9
Francois Bertel
francois.bertel at kitware.com
Fri Oct 17 18:56:23 EDT 2008
See VTK/Examples/Build/vtkLocal/ or VTK/Examples/Build/vtkLocal/vtkMy/
for an example of this mechanism.
On Fri, Oct 17, 2008 at 6:44 PM, Karthik Krishnan
<karthik.krishnan at kitware.com> wrote:
> You must explicitly export the classes and the global functions
> to be made publicly accessible.
>
> You need to define your own mylibrary_EXPORT directive with a
> line similar to what is done in VTK
>
> Create a file myLibraryConfigure.h.in and configure it..
> The file will have a line such as
> #cmakedefine MyLibrary_BUILD_SHARED_LIBS
>
> include this file from another file you will create myLibarys.h
>
> #if defined(_WIN32) && defined(MyLibrary_BUILD_SHARED_LIBS)
> # if defined(MyLibrary_EXPORTS)
> # define MyLibrary_EXPORT __declspec( dllexport )
> # else
> # define MyLibrary_EXPORT __declspec( dllimport )
> # endif
> #else
> # define MyLibrary_EXPORT
> #endif
>
> include this file from all the headers in your library and prefix them
> with MyLibrary_EXPORT.
>
> And set MyLibrary_BUILD_SHARED_LIBS to whatever BUILD_SHARED_LIBS
> is in your CMakeLists.txt.
>
> Assuming you have a ADD_LIBRARY when adding the files to your
> lib, mylibrary_EXPORTS will be defined by cmake so that you can know whether
> they are being included from inside their library our outside to
> properly setup dllexport/dllimport decorations.
>
>
> On Fri, Oct 17, 2008 at 6:30 PM, Dominik Szczerba <dominik at itis.ethz.ch> wrote:
>> I am building it externally, without recompiling VTK (5.2.0).
>>
>> DSZ
>>
>> On Saturday 18 October 2008 12:24:11 am Francois Bertel wrote:
>>> Where are you putting this class? in VTK/Graphics or in some external
>>> project?
>>>
>>> On Fri, Oct 17, 2008 at 6:16 PM, Dominik Szczerba <dominik at itis.ethz.ch>
>> wrote:
>>> > Yea I had a detailed look at vtkWin32Header.h and it should do as you say
>>> > - and as I do.
>>> > Looks to me like this is somehow broken with MSVS 9 2008 on derived
>>> > classes - was it tested with the new version?
>>> >
>>> > with regards,
>>> > Dominik
>>> >
>>> > On Saturday 18 October 2008 12:09:47 am Dominik Szczerba wrote:
>>> >> I am using:
>>> >>
>>> >> class VTK_GRAPHICS_EXPORT vtkThreshold2 : public
>>> >> vtkUnstructuredGridAlgorithm ...
>>> >>
>>> >> and I thought VTK_GRAPHICS_EXPORT does what you say, or do I miss
>>> >> anything?
>>> >>
>>> >> Dominik
>>> >>
>>> >> On Friday 17 October 2008 11:49:03 pm Karthik Krishnan wrote:
>>> >> > My guess is that you might be trying to use the classes on
>>> >> > windows without exporting them... the __declspec(dllimport) /
>>> >> > export thingie.
>>> >> >
>>> >> > You must explicitly export the classes and the global functions
>>> >> > to be made publicly accessible.
>>> >> >
>>> >> > See how VTK_FILTERING_EXPORT is used for instance... On unix,
>>> >> > this expands to nothing.
>>> >> >
>>> >> > On Fri, Oct 17, 2008 at 5:41 PM, Dominik Szczerba
>>> >> > <dominik at itis.ethz.ch>
>>> >>
>>> >> wrote:
>>> >> > > Compiling and linking to standard VTK classes work fine.
>>> >> > >
>>> >> > > As soon as I start using my own algorithms (e.g. derived from
>>> >> > > vtkUnstructuredGridAlgorithm) I get linking problems about
>>> >> > > unresolved New(), which I trace down to vtkStandardNewMacro. I see
>>> >> > > this macro goes very deep and suggests that so created objects must
>>> >> > > be somehow registered, but on linux the same code works just fine.
>>> >> > > What am I doing wrong?
>>> >> > >
>>> >> > > with regards,
>>> >> > > Dominik
>>> >> > > --
>>> >> > > Dominik Szczerba, Ph.D.
>>> >> > > Computational Physics Group
>>> >> > > Foundation for Research on Information Technologies in Society
>>> >> > > http://www.itis.ethz.ch
>>> >> > > _______________________________________________
>>> >> > > This is the private VTK discussion list.
>>> >> > > Please keep messages on-topic. Check the FAQ at:
>>> >> > > http://www.vtk.org/Wiki/VTK_FAQ Follow this link to
>>> >> > > subscribe/unsubscribe:
>>> >> > > http://www.vtk.org/mailman/listinfo/vtkusers
>>> >
>>> > --
>>> > Dominik Szczerba, Ph.D.
>>> > Computational Physics Group
>>> > Foundation for Research on Information Technologies in Society
>>> > http://www.itis.ethz.ch
>>> > _______________________________________________
>>> > This is the private VTK discussion list.
>>> > Please keep messages on-topic. Check the FAQ at:
>>> > http://www.vtk.org/Wiki/VTK_FAQ Follow this link to
>>> > subscribe/unsubscribe:
>>> > http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>>
>> --
>> Dominik Szczerba, Ph.D.
>> Computational Physics Group
>> Foundation for Research on Information Technologies in Society
>> http://www.itis.ethz.ch
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
>
>
> --
> Karthik Krishnan
> R&D Engineer,
> Kitware Inc.
> Ph: 518 371 3971 x119
> Fax: 518 371 3971
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
François Bertel, PhD | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
| Clifton Park NY 12065, USA
More information about the vtkusers
mailing list