Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 / 64 MinGW build #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[S]patially [O]riented [F]ormat for [A]coustics, C++ library.
==============================

Library for reading and writing the standartized .sofa file format (AES69-2015).

Changes to libSOFA-master:
------------

Added cmake build file and included static windows libraries (compiled with minGW on a x86 machine for both 32 and 64 bit targets). That means it should be possible to build libSOFA with this fork on windows 32/64Bit (running on x86 architecture) on-the-fly. Cmake and the minGW-w64 (both available for i686 [32Bit] and x64 [64Bit]) compiler is required.

Instructions to build dependencies from source:
------------

Ref.: This is a build instruction based on MSYS2 with the minGW compiler on windows. It can help you on other systems too, but there you wouldn't work with the MSYS2 console and the minGW compiler. There, you have to find the suitable command line instructions. Additionally, This is no general solution to serve all possible system situations. I'd like to see it more like a hint to get things work properly. We need curl, zlib, hdf5 and netcdf (c and c++).

Ok, here we go:

- Install MSYS2 from https://sourceforge.net/projects/msys2/ . Afterwards, an update is recommended. Open the MSYS2 console and type:

``pacman-syu`` >>>restart MSYS2 console<<< ``pacman -Su``

- We need a compiler. ``pacman -S mingw-w64-i686`` for 32 bit or ``pacman -S mingw-w64-x86_64`` for 64 bit minGW.

- Close the MSYS2 console and start the convenient mingw32 or mingw64 console (bash scripts in MSYS2 directory), pending on the compiler installation before (32 or 64 bit).

- You have to install several libraries and linux-like library wrappers: make, dlfcn, hdf5, netcdf, curl. ``pacman -Ss [fill on your own]`` plus a name hint will inform you about avilable up-to-date packages for each compiler, try ``pacman -Ss dlfcn`` and you'll see what I mean. Zlib is shipped with MinGW, so you don't need to install it.

- Unfortunalety, netcdf-c++4 is not available yet with pacman (maybe it is at the time when you read this? Try it with the command above). We need to build it from source. Download the netcdf_c++ unix-style source code (google will help you to find it) and navigate inside the mingw shell to the directory and configure the build with ``./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32`` with the 64 bit compiler version, or ``./configure --host=i686-w64-mingw32 --build=i686-w64-mingw32`` with the 32Bit compiler version. then ``make`` and ``make install`` will compile static libraries and place them in the mingw lib folder.

Congratulations, now you have all the required libraries in your MSYS/minGW library folder. Link to them when building libSOFA (easiest and dirtiest is to copy them into your source directory) and everything should work fine.
101 changes: 101 additions & 0 deletions libsofa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
project(libsofa)
cmake_minimum_required(VERSION 2.8)

#determine if working with 32 or 64 bit compiler
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Target is 64 bits")
set(SOFA_EXT_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib/win64" CACHE FILEPATH "description")
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Target is 32 bits")
set(SOFA_EXT_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib/win32" CACHE FILEPATH "description")
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
#additional shipped dependencies on windows
find_library(SZ_LIB szip HINTS ${SOFA_EXT_LIB_PATH})
find_library(M_LIB m ${SOFA_EXT_LIB_PATH})
find_library(DL_LIB dl ${SOFA_EXT_LIB_PATH})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(SOFA_EXT_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib/linux" CACHE FILEPATH "description")
#additional dependencies on linux, should be on system
#find_library(SZ_LIB szip) #linux library is compiled without szlib support
find_library(M_LIB m)
find_library(DL_LIB dl)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(SOFA_EXT_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/lib/macos" CACHE FILEPATH "description")
#additional dependencies on linux, should be on system
#find_library(SZ_LIB szip) #macos library is compiled without szlib support
find_library(M_LIB m)
find_library(DL_LIB dl)
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
message(SEND_ERROR "Unknown system name (does not equal Windows, linux or Darwin [Mac OS X])")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

set (SOFA_EXT_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/include" CACHE FILEPATH "description")

#Shipped libraries
find_library(HDF5_LIB hdf5 HINTS ${SOFA_EXT_LIB_PATH})
find_library(HDF5_HL_LIB hdf5_hl HINTS ${SOFA_EXT_LIB_PATH})
find_library(NETCDF_LIB netcdf HINTS ${SOFA_EXT_LIB_PATH})
find_library(NETCDF_CXX_LIB netcdf_c++4 HINTS ${SOFA_EXT_LIB_PATH})
find_library(CURL_LIB curl HINTS ${SOFA_EXT_LIB_PATH})
find_library(Z_LIB z HINTS ${SOFA_EXT_LIB_PATH})

include_directories(${SOFA_EXT_INCLUDE_PATH})

add_library(sofa STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAAPI.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAAPI.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAAttributes.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAAttributes.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFACoordinates.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFACoordinates.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFADate.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFADate.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAEmitter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAEmitter.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAExceptions.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAExceptions.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAFile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAFile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAHelper.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAHelper.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAListener.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAListener.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFANcFile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFANcFile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAPoint3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAPoint3.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAPosition.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAPosition.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAReceiver.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAReceiver.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASimpleFreeFieldHRIR.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASimpleFreeFieldHRIR.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASimpleFreeFieldSOS.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASimpleFreeFieldSOS.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASimpleHeadphoneIR.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASimpleHeadphoneIR.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAGeneralTF.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAGeneralTF.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAGeneralFIR.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAGeneralFIR.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASource.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFASource.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAString.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAUnits.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/SOFAUnits.h")

add_executable(sofainfo "${CMAKE_CURRENT_SOURCE_DIR}/src/sofainfo.cpp")
target_link_libraries(sofainfo sofa
${NETCDF_CXX_LIB} ${NETCDF_LIB}
${HDF5_HL_LIB} ${HDF5_LIB}
${SZ_LIB} ${Z_LIB}
${CURL_LIB} ${M_LIB} ${DL_LIB})

add_executable(sofamisc "${CMAKE_CURRENT_SOURCE_DIR}/src/sofamisc.cpp")
target_link_libraries(sofamisc sofa
${NETCDF_CXX_LIB} ${NETCDF_LIB}
${HDF5_HL_LIB} ${HDF5_LIB}
${SZ_LIB} ${Z_LIB}
${CURL_LIB} ${M_LIB} ${DL_LIB})
Binary file not shown.
Binary file added libsofa/dependencies/bin/win32/libhdf5-0.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win32/libhdf5_hl-0.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win32/libnetcdf.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win32/libszip-0.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win32/ncdump.exe
Binary file not shown.
Binary file added libsofa/dependencies/bin/win32/zlib1.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/libgcc_s_seh-1.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/libhdf5-0.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/libhdf5_hl-0.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/libnetcdf.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/libstdc++-6.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/libszip-0.dll
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/ncdump.exe
Binary file not shown.
Binary file added libsofa/dependencies/bin/win64/zlib1.dll
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libcurl.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libdl.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libhdf5.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libhdf5_hl.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libm.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libnetcdf.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libnetcdf_c++4.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libszip.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win32/libz.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libcurl.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libdl.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libhdf5.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libhdf5_hl.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libm.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libnetcdf.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libnetcdf_c++4.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libszip.a
Binary file not shown.
Binary file added libsofa/dependencies/lib/win64/libz.a
Binary file not shown.
3 changes: 2 additions & 1 deletion libsofa/src/SOFADate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ using namespace sofa;


#if ( SOFA_WINDOWS == 1 )
#include <sys/timeb.h>
#include <windows.h>
#include <sys/time.h>
#define literal64bit(longLiteral) ((__int64) longLiteral)
#else
#define literal64bit(longLiteral) (longLiteral##LL)
Expand Down