Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Statically link dependencies

$
0
0

Hi,

I'm having some issues statically linking some dependencies when building a DLL with Cmake on Windows. 

When I perform a regular MSVC build I do the following:

:: Sets up compiler environment 
CALL "%VS2017INSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" x64

:: Path gets very long and VS can no longer find cmd.exe if we don't prepend it
SET PATH=C:\windows\system32;%PATH%

:: Set vars to CMake and Ninja
SET CMAKE_EXE=%VS2017INSTALLDIR%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
SET NINJA_EXE=%VS2017INSTALLDIR%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe

:BuildRelWithDebInfo
MKDIR Temp\RelWithDebInfo 2> NUL
PUSHD Temp\RelWithDebInfo
:: Configure build for RelWithDebugInfo
CALL "%CMAKE_EXE%" -G "Ninja" ^
	-DCMAKE_INSTALL_PREFIX="%~dp0\Install\RelWithDebInfo" ^
	-DCMAKE_BUILD_TYPE="RelWithDebInfo" ^
	-DCMAKE_MAKE_PROGRAM="%NINJA_EXE%""%~dp0"

set ERRORCODE=%ERRORLEVEL%
IF %ERRORCODE% NEQ 0 (
	echo Failed to configure build for 'RelWithDebInfo'
	exit /B %ERRORCODE%
)

:: Build and install
CALL "%CMAKE_EXE%" --build . --target install

set ERRORCODE=%ERRORLEVEL%
IF %ERRORCODE% NEQ 0 (
	echo Failed to compile build and install for 'RelWithDebInfo'
	exit /B %ERRORCODE%
)

To build with the Intel compiler I do this instead:

CALL "%ICPP_COMPILER19%\bin\ipsxe-comp-vars.bat" intel64 vs2017

:: Sets up environment to find intel compiler tools
CALL "%ICPP_COMPILER19%\bin\ipsxe-comp-vars.bat" intel64 vs2017
:: Path gets very long and VS can no longer find cmd.exe if we don't prepend it
SET PATH=C:\windows\system32;%PATH%

:: Set vars to CMake and Ninja
SET CMAKE_EXE=%VS2017INSTALLDIR%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
SET NINJA_EXE=%VS2017INSTALLDIR%\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe

SET COMPILER_NAME=icl.exe

:BuildRelWithDebInfo
MKDIR Temp\Intel-RelWithDebInfo 2> NUL
PUSHD Temp\Intel-RelWithDebInfo
:: Configure build for RelWithDebugInfo
CALL "%CMAKE_EXE%" -G "Ninja" ^
	-DCMAKE_INSTALL_PREFIX="%~dp0\Install\Intel-RelWithDebInfo" ^
	-DCMAKE_BUILD_TYPE="RelWithDebInfo" ^
	-DCMAKE_MAKE_PROGRAM="%NINJA_EXE%" ^
	-DCMAKE_CXX_COMPILER="%COMPILER_NAME%" ^
	-DCMAKE_C_COMPILER="%COMPILER_NAME%" ^
	"%~dp0"

set ERRORCODE=%ERRORLEVEL%
IF %ERRORCODE% NEQ 0 (
	echo Failed to configure build for 'Intel-RelWithDebInfo'
	exit /B %ERRORCODE%
)

:: Build and install
CALL "%CMAKE_EXE%" --build . --target install

The only real differences are which batch to call to setup the dev environment and for Intel builds I set CMAKE_CXX_COMPILER and CMAKE_C_COMPILER to icl.exe. 

I'm statically linking against hdf5.lib and hdf5_cpp.lib which when I build with MSVC is fine.

When I build with the Intel compiler however the resultant DLL has a dependency on hdf5.dll and hdf5_cpp.dll. 

Is this something I can avoid? I can't find much information on this issue as all the google search turn up results about statically linking openmp. 

Has anyone else had an issue like this? It may entirely be a Cmake issue but I can't see how right now. 

 

TCE Open Date: 

Monday, November 25, 2019 - 09:20

Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>