[Insight-developers] ITK Shared Build with VS2012

Bruno Ronzani bruno.ronzani at oyez.fr
Mon Feb 4 10:46:18 EST 2013


Hey back,

I'm still stuck on it ! It's been days...

Here is a sample code : http://codepad.org/jXtJdRnK

But look, this is from itksys/Configure.h ... why "#if 0" ?!

Since there is no dll_export, i'm not surprised that ITK is always
built statically :(

/******/

/* Setup the export macro.  */
#if 0
# if defined(_WIN32) || defined(__CYGWIN__)
#  if defined(itksys_EXPORTS)
#   define itksys_EXPORT __declspec(dllexport)
#  else
#   define itksys_EXPORT __declspec(dllimport)
#  endif
# elif __GNUC__ >= 4
#  define itksys_EXPORT __attribute__ ((visibility("default")))
# else
#  define itksys_EXPORT
# endif
#else
# define itksys_EXPORT
#endif

/*****/

Thanks for you help,

Bruno


On Mon, Feb 4, 2013 at 2:46 PM, Bruno Ronzani <bruno.ronzani at oyez.fr> wrote:
> I just tried to add the osgDB::fstream class to my project :
>
> - copying both osgDB/fstream.h and osgDB/fstream.cpp to my project
> source dir, adding them to my project.
> - removing all the "DLL_EXPORT" macros, but keeping the namespaces
>
> => compilation succeeds, without any link error.
>
> If that can help...
>
> Thanks again,
>
> Bruno
>
> On Mon, Feb 4, 2013 at 2:33 PM, Bruno Ronzani <bruno.ronzani at oyez.fr> wrote:
>> Hello Brad,
>>
>> Thank you for your answer.
>>
>> You are right, here is the osgDB/fstream header :
>>
>> https://github.com/openscenegraph/osg/blob/master/include/osgDB/fstream
>>
>> As you can see, osg cleanly redefines its own fstream, but that should
>> not be a problem at all.
>>
>> I've read several times this issue with this kind of answer:
>>
>> "I have been using Visual Studio 2010 and fstreams and OSG DLLs with
>> no issues at all. The only possibility is you are compiling with
>> incompatible compiler options between OSG and your other library. All
>> files must be compiled /MD(d) and of course compiled with Visual
>> Studio 2010."
>>
>> My guess is I haven't really compiled ITK with /MD, don't you think ?
>>
>> If you want a very simple example, I can try to provide one.
>>
>> Thanks again,
>>
>> On Mon, Feb 4, 2013 at 1:56 PM, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:
>>> Hello,
>>>
>>> Are you using a CMake file to build your project?
>>>
>>> Can you boil down this issue to a minimal example to reproduce this error?
>>>
>>> What seems odd to me is that it sounds like osg92-osgDB.dll is export the std::basic_ifstream. So this may not even be an ITK issue.
>>>
>>> Brad
>>>
>>> On Feb 4, 2013, at 6:53 AM, Bruno Ronzani <bruno.ronzani at oyez.fr> wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> I am doing all I can to build ITK on VS2012, but I am experiencing a
>>>> lot of trouble...
>>>>
>>>> - I am using CMake.
>>>> - If I choose to build "static" (build_shared unchecked) ITK,
>>>> everything compiles fine.
>>>> - if I choose to build "shared" (build_shared checked), everything
>>>> compiles fine too. One ITKCommon-4.0.dll is created.
>>>>
>>>> Now here the trouble...
>>>>
>>>> When I try to compile a sample program with OpenSceneGraph, I have a
>>>> bunch of link errors of type :
>>>>
>>>> ITKMetaIO-4.0.lib(metaObject.obj) : error LNK2005: "public: __thiscall
>>>> std::basic_ifstream<char,struct std::char_traits<char>
>>>>> ::basic_ifstream<char,struct std::char_traits<char> >(void)"
>>>> (??0?$basic_ifstream at DU?$char_traits at D@std@@@std@@QAE at XZ) already
>>>> defined in osgDB.lib(osg92-osgDB.dll)
>>>>
>>>> Apparently, this kind of errors appear when a static library is linked
>>>> with a dynamic one...
>>>> I've checked in my "shared" ITK solution project : most of the
>>>> projects are still built in static mode.
>>>> I tried to force the "Use MFC in a Shared DLL" but it doesn't change anything.
>>>> If I force the Configuration Type to .dll, then I have a bunch of link
>>>> errors, like :
>>>>
>>>> unresolved external symbol __imp__RegCloseKey at 4 referenced in function
>>>> "public: static bool __cdecl
>>>> itksys::SystemTools::DeleteRegistryValue(char const *,enum
>>>> itksys::SystemTools::KeyWOW64)"
>>>> (?DeleteRegistryValue at SystemTools@itksys@@SA_NPBDW4KeyWOW64 at 12@@Z)
>>>>
>>>> Any idea ?
>>>>
>>>> Thank you very much !
>>>>
>>>> Cheers,
>>>>
>>>> Bruno
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://kitware.com/products/protraining.php
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>


More information about the Insight-developers mailing list