My naive workaround was wrong, the test crashes because the module has not
been initialized.
==18299== Invalid read of size 4
==18299== at 0x6E7FE84: pthread_mutex_lock (pthread_mutex_lock.c:50)
==18299== by 0x5F94F2C: mitk::Mutex::Lock() (usThreads_p.h:156)
==18299== by 0x5F95976:
mitk::MutexLock<mitk::Mutex>::MutexLock(mitk::Mutex&) (usThreads_p.h:181)
==18299== by 0x5FB97DA:
mitk::ModuleRegistry::UnRegister(mitk::ModuleInfo const*)
(usModuleRegistry.cpp:149)
==18299== by 0x6B70BDA: mitk::ModuleInitializer::~ModuleInitializer()
(XnatRest_init.cpp:24)
==18299== by 0x75E4D3C: __cxa_finalize (cxa_finalize.c:56)
==18299== by 0x6B62EF5: ??? (in
/home/espakm/src/NifTK-debug/NifTK-build/bin/libXnatRest2.so)
==18299== by 0x6B70E60: ??? (in
/home/espakm/src/NifTK-debug/NifTK-build/bin/libXnatRest2.so)
==18299== by 0x75E4920: __run_exit_handlers (exit.c:78)
==18299== by 0x75E49A4: exit (exit.c:100)
==18299== by 0x75CA773: (below main) (libc-start.c:258)
==18299== Address 0x10 is not stack'd, malloc'd or (recently) free'd
On Tue, Jul 17, 2012 at 11:50 AM, Miklos Espak <[email protected]> wrote:
> Hi,
>
>
> I ran into a weird error about linking a module test against its module.
> Building the test driver fails with this error:
>
> /home/espakm/src/NifTK/Code/Gui/MITK/Modules/XnatRest/Testing/XnatRestTest.cpp:52:
> undefined reference to `initXnatRest()'
>
> The function is defined in the module.
> However, I can link the test against a library that I created manually
> from the same sources. (With the add_library CMake function instead of the
> MITK_CREATE_MODULE macro.)
>
> Here is the CMakeLists.txt of the module:
>
>
> ------------------------------------------------------------------------------------------------------------------------
> # These should be automatically included, but it is not.
> include(${CMAKE_SOURCE_DIR}/CMake/PackageDepends/MITK_curl_Config.cmake)
>
> MITK_CREATE_MODULE(XnatRest
> EXPORT_DEFINE XnatRest_EXPORT
> PACKAGE_DEPENDS curl
> )
>
> # This library is built from the same sources as the module:
> add_library(XnatRest2 ${CPP_FILES})
> target_link_libraries(XnatRest2 curl)
>
> # add testing dir
> add_subdirectory(Testing)
>
> ------------------------------------------------------------------------------------------------------------------------
>
>
> And this is the CMakeLists.txt from the Testing directory:
>
>
>
> ------------------------------------------------------------------------------------------------------------------------
> MITK_CREATE_MODULE_TESTS()
>
> # This does not help:
> #target_link_libraries(XnatRestTestDriver XnatRest)
>
> # Only this solves the linker error:
> target_link_libraries(XnatRestTestDriver XnatRest2)
>
> ------------------------------------------------------------------------------------------------------------------------
>
>
> Does somebody have an idea why I cannot link the test against the module,
> but can do it to a library that is built from the same sources as the
> module?
>
> I put a string constant into the definition of the initXnatRest()
> function, just to check if it is built into both libraries. It is, the
> strings command has found it in both.
>
> I also added a debugging statement in the mitkMacroModuleTests.cmake file.
> Around line 35 I printed the add_executable and target_link_libraries
> statements:
>
> set(TESTDRIVER ${MODULE_NAME}TestDriver)
> message(STATUS "add_executable(${TESTDRIVER} ${MODULETEST_SOURCE}
> ${MODULE_TEST_GENERATED_MOC_CPP} ${TEST_CPP_FILES})")
> add_executable(${TESTDRIVER} ${MODULETEST_SOURCE}
> ${MODULE_TEST_GENERATED_MOC_CPP} ${TEST_CPP_FILES})
> message(STATUS "target_link_libraries(${TESTDRIVER} ${MODULE_PROVIDES}
> ${ALL_LIBRARIES})")
> target_link_libraries(${TESTDRIVER} ${MODULE_PROVIDES}
> ${ALL_LIBRARIES})
>
> The output:
>
> -- add_executable(XnatRestTestDriver
> XnatRestTestDriver.cpp;XnatRestTest.cpp )
> -- target_link_libraries(XnatRestTestDriver XnatRest
> curl;Mitk;mbilog;tinyxml;ITKAlgorithms;ITKStatistics;ITKFEM;ITKQuadEdgeMesh;vtkGraphics;vtkCommon;vtkFiltering;vtkftgl;vtkGraphics;vtkHybrid;vtkImaging;vtkIO;vtkParallel;vtkRendering;vtkVolumeRendering;vtkWidgets;vtkjpeg;vtkpng;vtkzlib;vtkexpat;vtkfreetype)
>
> I don't see anything wrong with this.
>
> Any idea?
>
> Thank you very much,
> Miklos
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users