View Issue Details

IDProjectCategoryView StatusLast Update
0029377Open CASCADEOCCT:Configurationpublic2018-06-29 21:19
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformWindowsOSVC++ 2010 
Product Version7.2.0 
Target Version7.3.0Fixed in Version7.3.0 
Summary0029377: Configuration, CMake - linkage errors while using static OCCT libraries on Windows platform
DescriptionThe following linkage errors occur while trying to use static OCCT libraries within application:
1>Link:
1>     Creating library C:\OccTest\bin64\Release\OccTest.lib and object C:\OccTest\bin64\Release\OccTest.exp
1>TKLCAF.lib(TDataStd_HDataMapOfStringString.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKCDF.lib(CDM_Document.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKCDF.lib(CDM_MetaData.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKCDF.lib(CDF_Application.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDataStd_HDataMapOfStringHArray1OfInteger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDataStd_HDataMapOfStringHArray1OfReal.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDataStd_HDataMapOfStringInteger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDataStd_HDataMapOfStringReal.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKBinL.lib(BinMDataStd_NamedDataDriver.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDocStd_Application.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDataStd_NamedData.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>TKLCAF.lib(TDataStd_HDataMapOfStringByte.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl HashCode(unsigned short const * const,int)" (__imp_?HashCode@@YAHQEBGH@Z)
1>C:\OccTest\bin64\Release\OccTest.dll : fatal error LNK1120: 1 unresolved externals


The reason is a weird combination of dllimport/dllexport by OCCT toolkits - seems to be by C functions first of all exported by __Standard_API/__Draw_API etc specific to Windows.

There is a special macros HAVE_NO_DLL which is intended to disable these dllimport/dllexport, however this macros is not defined by any build procedure, including CMake scripts.
Steps To Reproduce
@echo OFF

rem Auxiliary script for semi-automated building of OCCT for vc10-64 platform (static libraries).
rem Script should be placed into root of OCCT repository, edited with paths to CMake and 3rd-parties.

rem CMake can be downloaded from official site:
rem https://cmake.org/download/

set "aCasSrc=%~dp0"
set aNbJobs=%NUMBER_OF_PROCESSORS%

set "PATH=c:\work\Develop\SDKs\CMake\bin;%PATH%"

set "aFreeType=c:/workssd/Develop/3rdparty/vc10/freetype-2.7.1-vc10-64"
set "aTclTk=c:/workssd/Develop/3rdparty/vc10/tcltk-86-64"
set "aFreeImage=c:/workssd/Develop/3rdparty/vc10/freeimage-3.17.0-vc10-64"
set "DevEnvDir=%VS100COMNTOOLS%..\IDE"

call :cmakeGenerate

pause

goto :eof

:cmakeGenerate
set "aPlatformAndCompiler=vc10-64-static"
set "aWorkDir=work\%aPlatformAndCompiler%-make"
set "aLogFile=%~dp0build-%aPlatformAndCompiler%.log"
if not exist "%aWorkDir%" ( mkdir "%aWorkDir%" )
if     exist "%aLogFile%" ( del   "%aLogFile%" )

pushd "%aWorkDir%"

set STARTTIME=%TIME%
echo Configuring OCCT for MinGW-w64...
cmake -G "Visual Studio 10 2010 Win64" ^
 -D CMAKE_BUILD_TYPE:STRING="Release" ^
 -D BUILD_LIBRARY_TYPE:STRING="Static" ^
 -D BUILD_MODULE_Draw:BOOL="OFF" ^
 -D BUILD_MODULE_MfcSamples:BOOL="OFF" ^
 -D INSTALL_DIR:PATH="%~dp0work/%aPlatformAndCompiler%" ^
 -D INSTALL_DIR_INCLUDE:STRING="inc" ^
 -D INSTALL_DIR_RESOURCE:STRING="src" ^
 -D 3RDPARTY_FREETYPE_DIR:PATH="%aFreeType%" ^
 -D 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2:FILEPATH="%aFreeType%/include" ^
 -D 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build:FILEPATH="%aFreeType%/include" ^
 -D 3RDPARTY_FREETYPE_LIBRARY_DIR:PATH="%aFreeType%/lib" ^
 -D 3RDPARTY_TCL_DIR:PATH="%aTclTk%" ^
 -D 3RDPARTY_TCL_INCLUDE_DIR:FILEPATH="%aTclTk%/include" ^
 -D 3RDPARTY_TCL_LIBRARY_DIR:PATH="%aTclTk%/lib" ^
 -D 3RDPARTY_TCL_DLL_DIR:PATH="%aTclTk%/bin" ^
 -D 3RDPARTY_TK_DIR:PATH="%aTclTk%" ^
 -D 3RDPARTY_TK_INCLUDE_DIR:FILEPATH="%aTclTk%/include" ^
 -D 3RDPARTY_TK_LIBRARY_DIR:PATH="%aTclTk%/lib" ^
 -D 3RDPARTY_TK_DLL_DIR:PATH="%aTclTk%/bin" ^
 -D USE_D3D:BOOL="ON" ^
 -D USE_FREEIMAGE:BOOL="ON" ^
 -D 3RDPARTY_FREEIMAGE_DIR:PATH="%aFreeImage%" ^
 -D 3RDPARTY_FREEIMAGE_INCLUDE_DIR:FILEPATH="%aFreeImage%/include" ^
 -D 3RDPARTY_FREEIMAGE_LIBRARY_DIR:PATH="%aFreeImage%/lib" ^
 "%aCasSrc%"

if errorlevel 1 (
  popd
  pause
  exit /B
  goto :eof
)

set "PRJFILE=%~dp0%aWorkDir%\OCCT.sln"
"%DevEnvDir%\devenv.com" "%PRJFILE%" /clean "Release|x64"

echo Building OCCT...
"%DevEnvDir%\devenv.com" "%PRJFILE%" /build "Release|x64" 2>> %aLogFile%

type %aLogFile%
if errorlevel 1 (
  popd
  pause
  exit /B
  goto :eof
)
rem echo Installing OCCT into %~dp0work/%aPlatformAndCompiler%...

set ENDTIME=%TIME%
rem handle time before 10AM (win10 - remove empty space at the beginning)
if "%STARTTIME:~0,1%"==" " set "STARTTIME=%STARTTIME:~1%"
if   "%ENDTIME:~0,1%"==" " set   "ENDTIME=%ENDTIME:~1%"
rem handle time before 10AM (win7 - add 0 at the beginning)
if "%STARTTIME:~1,1%"==":" set "STARTTIME=0%STARTTIME%"
if   "%ENDTIME:~1,1%"==":" set   "ENDTIME=0%ENDTIME%"
rem convert hours:minutes:seconds:ms into duration
set /A STARTTIME=(1%STARTTIME:~0,2%-100)*360000 + (1%STARTTIME:~3,2%-100)*6000 + (1%STARTTIME:~6,2%-100)*100 + (1%STARTTIME:~9,2%-100)
set /A   ENDTIME=  (1%ENDTIME:~0,2%-100)*360000 +   (1%ENDTIME:~3,2%-100)*6000 +   (1%ENDTIME:~6,2%-100)*100 +   (1%ENDTIME:~9,2%-100)
set /A DURATION=%ENDTIME%-%STARTTIME%
if %ENDTIME% LSS %STARTTIME% set set /A DURATION=%STARTTIME%-%ENDTIME%
set /A DURATIONH=%DURATION% / 360000
set /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
set /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
if %DURATIONH% LSS 10 set DURATIONH=0%DURATIONH%
if %DURATIONM% LSS 10 set DURATIONM=0%DURATIONM%
if %DURATIONS% LSS 10 set DURATIONS=0%DURATIONS%
echo Building time: %DURATIONH%:%DURATIONM%:%DURATIONS% for %anAbi%
echo Building time: %DURATIONH%:%DURATIONM%:%DURATIONS% >> %aLogFile%

popd
goto :eof
TagsNo tags attached.
Test case numberNot required

Relationships

related to 0028983 closedbugmaster Community Configuration - HAVE_NO_DLL causes compilation to fail on MSVC 
has duplicate 0029390 closedabv Community Compilation problem 
related to 0029046 closedSchaeffer AG Community Problem with OCCT static build with MinGW 

Activities

git

2017-12-08 15:13

administrator   ~0072862

Branch CR29377 has been created by kgv.

SHA-1: b2e3d85cb7acc00b45111ebe5b54314452130154


Detailed log of new commits:

Author: kgv
Date: Fri Dec 8 15:13:14 2017 +0300

    0029377: Configuration, CMake - linkage errors while using static OCCT libraries on Windows platform
    
    HAVE_NO_DLL is now defined when building Static libraries.

kgv

2017-12-08 15:15

developer   ~0072863

Last edited: 2017-12-08 15:21

Patch is ready for review.

HAVE_NO_DLL should be also defined at application level to avoid linkage working like:
1>OccTest.obj : warning LNK4049: locally defined symbol ?HashCode@@YAHQEBDH@Z (int __cdecl HashCode(char const * const,int)) imported


It might be reasonable renaming macros HAVE_NO_DLL to OCCT_NO_DLL for consistency with other macros,
but this should be documented change since, apparently, some advanced users are already using it.

Making a "Static" build with HAVE_NO_DLL also reduces building time from 00:20:54 to 00:16:51.

abv

2017-12-18 07:11

manager   ~0073008

Reviewed, please integrate.

Other corrections related to static builds should be made within #22651

git

2018-01-11 11:10

administrator   ~0073326

Branch CR29377 has been deleted by kgv.

SHA-1: b2e3d85cb7acc00b45111ebe5b54314452130154

Related Changesets

occt: master 77cd443b

2017-12-08 12:13:14

kgv


Committer: bugmaster Details Diff
0029377: Configuration, CMake - linkage errors while using static OCCT libraries on Windows platform

HAVE_NO_DLL is now defined when building Static libraries.
Affected Issues
0029377
mod - adm/cmake/occt_toolkit.cmake Diff File
mod - adm/cmake/occt_toolkit_tool.cmake Diff File
mod - dox/dev_guides/building/cmake/cmake.md Diff File

Issue History

Date Modified Username Field Change
2017-12-08 14:57 kgv New Issue
2017-12-08 14:57 kgv Assigned To => kgv
2017-12-08 15:13 git Note Added: 0072862
2017-12-08 15:15 kgv Note Added: 0072863
2017-12-08 15:15 kgv Assigned To kgv => abv
2017-12-08 15:15 kgv Status new => resolved
2017-12-08 15:16 kgv Note Edited: 0072863
2017-12-08 15:16 kgv Relationship added related to 0028983
2017-12-08 15:21 kgv Note Edited: 0072863
2017-12-18 07:11 abv Note Added: 0073008
2017-12-18 07:11 abv Assigned To abv => bugmaster
2017-12-18 07:11 abv Status resolved => reviewed
2017-12-18 07:18 abv Relationship added related to 0029046
2017-12-18 12:03 bugmaster Status reviewed => tested
2017-12-18 12:52 bugmaster Test case number => Not required
2017-12-18 14:16 abv Relationship added has duplicate 0029390
2017-12-23 12:07 bugmaster Changeset attached => occt master 77cd443b
2017-12-23 12:07 bugmaster Status tested => verified
2017-12-23 12:07 bugmaster Resolution open => fixed
2018-01-11 11:10 git Note Added: 0073326
2018-06-29 21:15 aiv Fixed in Version => 7.3.0
2018-06-29 21:19 aiv Status verified => closed