[ITK Community] [Insight-users] Multiple shared libraries and linking error: itk_nrrdSpaceDimension already defined

Barbara Post bpo at eonix.be
Wed Mar 12 12:06:32 EDT 2014


Hello,

I'm not sure about what I should change in my project.
I read
https://issues.itk.org/jira/browse/ITK-2861?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab so this indicates the error is from me, not ITK.

I build a shared library that is a custom Qt4 plugin. I use another set of libraries MYOTHERLIB that provides an itk-tools.dll shared lib with classes dedicating to talking to ITK.

I use MSVC 2010 64 bit compiler, compiled ITK with it.

My error when compiling :
LNK2005: itk_nrrdSpaceDimension already defined in itk-tools.lib(itk-tools.dll)

itk-tools base class, XITKTools, has following ITK includes:

#include <itkImage.h>
#include <itkImageFileWriter.h>
#include <itkImageFileReader.h>
#include <itkMinimumMaximumImageCalculator.h>
#include <itkImageMaskSpatialObject.h>

What else could I check about includes/linkings?

Thanks,

Barbara

My CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.8)

project(applet-tutorial2)

FIND_PACKAGE(Qt4 REQUIRED)

if (QT4_FOUND)
    INCLUDE(${QT_USE_FILE})
else()
    message(FATAL_ERROR "No Qt4 found")
endif()

FIND_PACKAGE(ITK REQUIRED)

if(ITK_FOUND)
    include(${ITK_USE_FILE})
else()
    message(FATAL_ERROR "No ITK found")
endif()

# define path to MYOTHERLIB platform, relying on environment variable
IF(CMAKE_BUILD_TYPE MATCHES Debug)
    SET(MYOTHERLIB_DIR "$ENV{MYOTHERLIB}/debug")
    MESSAGE(STATUS "Debug build")
ELSE()
    SET(MYOTHERLIB_DIR "$ENV{MYOTHERLIB}/relWithDebInfo")
    MESSAGE(STATUS "Not debug build")
ENDIF()

# define cmake subdirectory
set(MYOTHERLIB_CMAKE_DIR cmake)
# required for find_package directive to work
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/${MYOTHERLIB_CMAKE_DIR})

# Find MYOTHERLIB platform installation
find_package(MYOTHERLIBPlatform REQUIRED)

# application headers files
SET(applet_tutorial2_HEADERS
[snip]
)
# application files: source files
# and every file we want to show up in project files tree
# (headers and other files)
SET(applet_tutorial2_SOURCES
    ${applet_tutorial2_HEADERS}
[snip]
)

SET(applet_tutorial2_RESOURCES resources/resources.qrc)

# Use AutoMoc
SET(CMAKE_AUTOMOC ON)
# Resources
QT4_ADD_RESOURCES(applet_tutorial2_RESOURCES_RCC ${applet_tutorial2_RESOURCES})

# all includes
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${MYOTHERLIB_DIR}/include"
"${MYOTHERLIB_DIR}/include/foundation"
"${MYOTHERLIB_DIR}/include/logger"
"${MYOTHERLIB_DIR}/include/container-data"
"${MYOTHERLIB_DIR}/include/dicom"
"${MYOTHERLIB_DIR}/include/itk-tools"
${CMAKE_CURRENT_BINARY_DIR}
)

# linking
link_directories("${MYOTHERLIB_DIR}/lib")

# build shared library (syntax: name, type, list of files)
add_library(
    applet-tutorial2 SHARED
    ${applet_tutorial2_SOURCES}
    ${applet_tutorial2_HEADERS}
)

# linking. Variables are defined by find_library() call in MYOTHERLIB_config.cmake
# MYOTHERLIB defines 5 *_LIB variables below.
target_link_libraries(
    applet-tutorial2
    ${QT_LIBRARIES}
    ${ITK_LIBRARIES}
    ${foundation_LIB}
    ${logger_LIB}
    ${container-data_LIB}
    ${dicom_LIB}
    ${itk-tools_LIB}
)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140312/c0636545/attachment-0002.html>
-------------- next part --------------
_____________________________________
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://www.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-users


More information about the Community mailing list