Skip to content

Commit

Permalink
Fixes for file format plugins on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertLitjens committed Jan 17, 2017
1 parent 855339a commit 08a72ab
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 13 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ IF(NOT WIN32)
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:$ORIGIN/")
ENDIF(NOT WIN32)

set (CMAKE_CXX_STANDARD 11)

# Set compile definitions to ignore some warnings
if (WIN32)
set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS}
Expand Down Expand Up @@ -146,4 +148,4 @@ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ASAP - Automated Slide Analysis Platform")
set(CPACK_PACKAGING_INSTALL_PREFIX /opt/ASAP)
ENDIF(WIN32)
INCLUDE(CPack)
ENDIF(PACKAGE_ON_INSTALL)
ENDIF(PACKAGE_ON_INSTALL)
2 changes: 1 addition & 1 deletion cmakemodules/FindOPENSLIDE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# OPENSLIDE_FOUND, If false, do not try to use OPENSLIDE.

find_path(OPENSLIDE_INCLUDE_DIR openslide.h)
find_library(OPENSLIDE_LIBRARY NAMES OPENSLIDE)
find_library(OPENSLIDE_LIBRARY NAMES openslide)

# handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if
# all listed variables are TRUE
Expand Down
3 changes: 2 additions & 1 deletion cmakemodules/FindUNITTEST.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

find_path(UNITTEST_INCLUDE_DIR UnitTest++.h)
find_library(UNITTEST_LIBRARY NAMES UNITTEST)
find_library(UNITTEST_LIBRARY_DEBUG NAMES UNITTEST)

# handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(UNITTEST
REQUIRED_VARS UNITTEST_LIBRARY UNITTEST_INCLUDE_DIR)
REQUIRED_VARS UNITTEST_LIBRARY UNITTEST_LIBRARY_DEBUG UNITTEST_INCLUDE_DIR)

if(UNITTEST_FOUND)
set( UNITTEST_LIBRARIES ${UNITTEST_LIBRARY} )
Expand Down
6 changes: 3 additions & 3 deletions config/ASAPMacros.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef __ASAPMACROS_H__
#define __ASAPMACROS_H__

#define ASAP_MAJOR_VERSION = @CURRENT_MAJOR_VERSION@
#define ASAP_MINOR_VERSION = @CURRENT_MINOR_VERSION@
#define ASAP_PATCH_VERSION = @CURRENT_PATCH_VERSION@
#define ASAP_MAJOR_VERSION @CURRENT_MAJOR_VERSION@
#define ASAP_MINOR_VERSION @CURRENT_MINOR_VERSION@
#define ASAP_PATCH_VERSION @CURRENT_PATCH_VERSION@
static const char* ASAP_VERSION_STRING = "@CURRENT_MAJOR_VERSION@.@CURRENT_MINOR_VERSION@.@CURRENT_PATCH_VERSION@";

#ifdef __WIN32__
Expand Down
2 changes: 1 addition & 1 deletion imgproc/NucleiSegmentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ INSTALL(TARGETS NucleiSegmentation
)

INSTALL(FILES FRST.h DESTINATION include/imgproc/NucleiSegmentation)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/NucleiSegmentation_export.h DESTINATION include/imgproc/NucleiSegmentation)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/nucleisegmentation_export.h DESTINATION include/imgproc/NucleiSegmentation)
2 changes: 1 addition & 1 deletion imgproc/wholeslide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ IF(WRAP_WHOLESLIDEFILTERS_PYTHON)

set_source_files_properties(wholeslidefilters.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties(wholeslidefilters.i PROPERTIES SWIG_FLAGS "-builtin")
include_directories(. ${PYTHON_INCLUDE_DIR} ${DIAGPathology_BINARY_DIR})
include_directories(. ${PYTHON_INCLUDE_DIR} ${DIAGPathology_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
SWIG_ADD_MODULE(wholeslidefilters python wholeslidefilters.i)
SWIG_LINK_LIBRARIES(wholeslidefilters wholeslidefilters core)
SWIG_LINK_LIBRARIES(wholeslidefilters ${PYTHON_LIBRARIES} ${PYTHON_DEBUG_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion io/multiresolutionimageinterface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ INSTALL(TARGETS multiresolutionimageinterface
INSTALL(TARGETS openslidefileformat
EXPORT asap-targets
RUNTIME DESTINATION bin/formats
LIBRARY DESTINATION lib
LIBRARY DESTINATION bin/formats
ARCHIVE DESTINATION lib
)
2 changes: 1 addition & 1 deletion io/multiresolutionimageinterface/MultiResolutionImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ template <> void MULTIRESOLUTIONIMAGEINTERFACE_EXPORT MultiResolutionImage::getR
template <> void MULTIRESOLUTIONIMAGEINTERFACE_EXPORT MultiResolutionImage::getRawRegion(const long long& startX, const long long& startY, const unsigned long long& width,
const unsigned long long& height, const unsigned int& level, float*& data);

#endif
#endif
17 changes: 15 additions & 2 deletions io/multiresolutionimageinterface/MultiResolutionImageFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ void MultiResolutionImageFactory::registerExternalFileFormats() {
pathStr = std::string(path);
#else
Dl_info dlInfo;
dladdr(&MultiResolutionImageFactory::registerExternalFileFormats, &dlInfo);
dladdr((void*)&MultiResolutionImageFactory::registerExternalFileFormats, &dlInfo);
pathStr = std::string(dlInfo.dli_fname);
#endif
std::string rootDir = core::extractFilePath(pathStr);
std::string fileFormatPluginDir = core::completePath("formats", rootDir);
std::vector<std::string> formatPlugins;
#ifdef _WIN32
std::string fileFormatPluginDir = core::completePath("formats", rootDir);
core::getFiles(fileFormatPluginDir, "*.dll", formatPlugins);
#else
std::string fileFormatPluginDir = core::completePath("bin/formats", core::upOneLevel(rootDir));
core::getFiles(fileFormatPluginDir, "*.so", formatPlugins);
#endif
for (std::vector<std::string>::const_iterator it = formatPlugins.begin(); it != formatPlugins.end(); ++it) {
#ifdef _WIN32
SetDllDirectory(rootDir.c_str());
Expand All @@ -85,6 +90,14 @@ void MultiResolutionImageFactory::registerExternalFileFormats() {
else {
DWORD test = GetLastError();
}
#else
void *hndl = dlopen(core::completePath((*it), fileFormatPluginDir).c_str(), RTLD_NOW);
if(hndl != NULL){
FileFormatLoader loadfunction = (FileFormatLoader)dlsym(hndl, "filetypeLoad");
if (loadfunction) {
(*loadfunction)();
}
}
#endif
}
MultiResolutionImageFactory::_externalFormatsRegistered = true;
Expand Down
3 changes: 2 additions & 1 deletion io/multiresolutionimageinterface/VSIImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <math.h>
#include "core/filetools.h"
#include "core/Box.h"
Expand Down Expand Up @@ -300,7 +301,7 @@ void* VSIImage::readDataFromImage(const long long& startX, const long long& star
for (int trow=0; trow<intersection.getSize()[1]; trow++) {
int realRow = trow + intersection.getStart()[1] - tile.getStart()[1];
int inputOffset = 3 * (realRow * width + intersectionX);
memcpy(data+outputOffset, tileBuf+inputOffset, rowLen);
std::memcpy(data+outputOffset, tileBuf+inputOffset, rowLen);
outputOffset += outputRowLen;
}

Expand Down

0 comments on commit 08a72ab

Please sign in to comment.