[Insight-users] dynamic loader + GDCM

Mathieu Malaterre mathieu.malaterre at kitware.com
Mon Sep 12 11:01:32 EDT 2005


Stephan,

	Here is the test for me (after changing the hardcoded path to 
libadll.so to the correct one):

$ ./amain 

address of handle: 0x5cc270
Getting function address from lib
Casting function address from lib
Calling function from lib
Hello, we are in the dll-function afunc!
End of function afunc
Closing libs
Exiting

$ echo $? 

0

$ uname -a 
                                                     Linux 
farsight-gentoo 2.6.9-gentoo-r14 #6 SMP Sun Jan 30 20:24:14 EST 2005 
x86_64 AMD Opteron(tm) Processor 848 AuthenticAMD GNU/Linux

$ gcc --version 
                                                     gcc (GCC) 3.4.4 
(Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)


Did you do any kind of system update and the compiler used to compile 
ITK would be different from the one you use to compile your small demo ?

Could you run valgrind on your program to help us find out what is going 
on, on your system ? (Please note that for AMD64 you need *at least* 
valgrind 3.0.1).

Thanks
Mathieu


Stefan Klein wrote:
> Hello,
> 
> We have a problem with using the itkDynamicLoader in combination with 
> the GDCM library.
> 
> A little test program is attached to this email.
> In the main function (defined in amain.cxx), we are trying to load a 
> dynamic library at runtime. In the attached example this library is 
> called "libadll.so". In this library one function is defined, called 
> "afunc", which does nothing more than printing some stuff to the screen 
> and creating an instance of the GDCMImageIO class. After calling 'afunc' 
> from the lib the main program also creates an instance of the 
> GDCMImageIO class. No errors occur until this moment, but when closing 
> the program a SEGMENTATION FAULT is generated.
> 
> The problem does not occur with other imageIO classes.
> 
> We use:
> GCC 3.4.2 on a 64bit linux system (AMD opteron).
> ITK 2.2, compiled with CMAKE_C_FLAGS and CMAKE_CXX_FLAGS set to -fPIC. 
> This is necessary, otherwise the program does not compile at all.
> 
> With ITK 2.0 an other error is given on exiting:
> *** glibc detected *** double free or corruption (!prev): 
> 0x000000000061d0e0 ***
> 
> Any ideas on what the problem is in the GDCM library?  Can anybody 
> reproduce this error?
> 
> Apart from this problem with the GDCM library, we noticed that the 
> ::LastError() function in the itk::DynamicLoader does not work at all. 
> It produces a segmentation fault.
> 
> Thanks in advance,
> 
> Marius Staring and Stefan Klein.
> 
> 
> ------------------------------------------------------------------------
> 
> PROJECT(testDLL)
> 
> # Find ITK.
> FIND_PACKAGE(ITK)
> IF(ITK_FOUND)
>   INCLUDE(${ITK_USE_FILE})
> ELSE(ITK_FOUND)
>   MESSAGE(FATAL_ERROR
>           "Cannot build without ITK.  Please set ITK_DIR.")
> ENDIF(ITK_FOUND)
> 
> ADD_LIBRARY(adll MODULE adll.cxx)
> TARGET_LINK_LIBRARIES(adll ITKCommon ITKIO  )
> 
> ADD_EXECUTABLE(amain amain.cxx )
> TARGET_LINK_LIBRARIES(amain ITKCommon ITKIO)
> 
> INSTALL_TARGETS(/. adll amain)
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list