areaDetector / ADSupport

Source code for support libraries for areaDetector.
https://areadetector.github.io/areaDetector/user_guide.html
Other
1 stars 15 forks source link

unresolved external symbols when linking NeXus.dll #2

Closed kmpeters closed 8 years ago

kmpeters commented 8 years ago

I'm getting the following link error when building ADSupport dynamically using both VS2010 and VS2015 against both base-3.14.12.5 and base-3.15.4:

cl -c                /nologo /D__STDC__=0 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE   /Ox /GL   /W3 /w44355     -DHDF5 -D_FILE_OFFSET_BITS=64 -DH5_
NO_DEPRECATED_SYMBOLS -DH5Gopen_vers=2 -DDLL_NEXUS -DH5_BUILT_AS_STATIC_LIB -DDLL_EXPORT    /MD     -I. -I..\\O.Common -I. -I..\\os\\WIN32 -I..\\os\\default -I.
. -I..\\..\\..\\include\\os\\WIN32 -I..\\..\\..\\include     -ID:\\synApps-testing\\VS10\\3.14\\base-3.14.12.5\\include\\os\\WIN32 -ID:\\synApps-testing\\VS10\\
3.14\\base-3.14.12.5\\include    -ID:\\synApps-testing\\VS10\\3.14\\synApps\\support\\asyn\\include -ID:\\synApps-testing\\VS10\\3.14\\synApps\\support\\areaDet
ector\\ADSupport\\include\\os\\WIN32 -ID:\\synApps-testing\\VS10\\3.14\\synApps\\support\\areaDetector\\ADSupport\\include  -ID:\\synApps-testing\\VS10\\3.14\\s
ynApps\\support\\areaDetector\\ADCore\\include                  ..\\stptok.c
stptok.c
link /nologo /subsystem:windows /dll /LTCG /incremental:no /opt:ref /release        /implib:NeXus.lib /out:NeXus.dll         napi.obj napi5.obj napiu.obj nxdata
set.obj nxio.obj nxstack.obj nxxml.obj stptok.obj       ..\\..\\..\\lib\\win32-x86\\hdf5.lib  ..\\..\\..\\lib\\win32-x86\\szip.lib  ..\\..\\..\\lib\\win32-x86\\
zlib.lib
   Creating library NeXus.lib and object NeXus.exp
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_SHORT_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_INT32_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_INT_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_INT8_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_UINT64_g
napi5.obj : error LNK2001: unresolved external symbol _H5P_CLS_DATASET_CREATE_ID_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_USHORT_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_UINT_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_UCHAR_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_SCHAR_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_FLOAT_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_UINT8_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_C_S1_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_INT16_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_UINT16_g
napi5.obj : error LNK2001: unresolved external symbol _H5P_CLS_FILE_ACCESS_ID_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_UINT32_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_INT64_g
napi5.obj : error LNK2001: unresolved external symbol _H5T_NATIVE_DOUBLE_g
NeXus.dll : fatal error LNK1120: 19 unresolved externals
D:/synApps-testing/VS10/3.14/base-3.14.12.5/configure/RULES_BUILD:300: recipe for target 'NeXus.dll' failed
make[5]: *** [NeXus.dll] Error 1120
make[5]: Leaving directory 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector/ADSupport/supportApp/nexusSrc/O.win32-x86'
D:/synApps-testing/VS10/3.14/base-3.14.12.5/configure/RULES_ARCHS:64: recipe for target 'install.win32-x86' failed
make[4]: *** [install.win32-x86] Error 2
make[4]: Leaving directory 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector/ADSupport/supportApp/nexusSrc'
D:/synApps-testing/VS10/3.14/base-3.14.12.5/configure/RULES_DIRS:87: recipe for target 'nexusSrc.install' failed
make[3]: *** [nexusSrc.install] Error 2
make[3]: Leaving directory 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector/ADSupport/supportApp'
D:/synApps-testing/VS10/3.14/base-3.14.12.5/configure/RULES_DIRS:87: recipe for target 'supportApp.install' failed
make[2]: *** [supportApp.install] Error 2
make[2]: Leaving directory 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector/ADSupport'
D:/synApps-testing/VS10/3.14/base-3.14.12.5/configure/RULES_DIRS:87: recipe for target 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector/ADSupport.inst
all' failed
make[1]: *** [D:/synApps-testing/VS10/3.14/synApps/support/areaDetector/ADSupport.install] Error 2
make[1]: Leaving directory 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector'
D:/synApps-testing/VS10/3.14/base-3.14.12.5/configure/RULES_DIRS:87: recipe for target 'D:/synApps-testing/VS10/3.14/synApps/support/areaDetector.install' faile
d
make: *** [D:/synApps-testing/VS10/3.14/synApps/support/areaDetector.install] Error 2

I suspect something may be wrong with my CONFIG_SITE.local. Here are the relevant values from it:

$ grep WITH synApps/support/areaDetector/configure/CONFIG_SITE.local
# WITH_XXX      Build the plugins and drivers that require this library.
WITH_BOOST     = NO
WITH_EPICS_V4  = NO
WITH_GRAPHICSMAGICK     = NO
WITH_HDF5     = YES
WITH_JPEG     = YES
WITH_NETCDF     = YES
WITH_NEXUS     = YES
WITH_OPENCV     = NO
WITH_SZIP     = YES
WITH_TIFF     = YES
WITH_XML2     = YES
WITH_ZLIB     = YES

$ grep EXTERNAL synApps/support/areaDetector/configure/CONFIG_SITE.local
#               Build the source code for this library in ADSupport if XXX_EXTERNAL=NO.
# XXX_EXTERNAL  If NO then build the source code for this library in ADSupport.
# XXX_INCLUDE   If XXX_EXTERNAL=YES then this is the path to the include files for XXX.
# XXX_LIB       If XXX_EXTERNAL=YES then this is the path to the library files for XXX.
BOOST_EXTERNAL = YES
GRAPHICSMAGICK_EXTERNAL = YES
HDF5_EXTERNAL = NO
JPEG_EXTERNAL = NO
NETCDF_EXTERNAL = NO
NEXUS_EXTERNAL = NO
OPENCV_EXTERNAL = YES
SZIP_EXTERNAL = NO
TIFF_EXTERNAL = NO
XML2_EXTERNAL = NO
ZLIB_EXTERNAL = NO

Is something obviously misconfigured?

MarkRivers commented 8 years ago

I can't reproduce this problem. I am using Visual Studio 2010, base 3.14.12.5.

cl -c                /nologo /D__STDC__=0 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE   /Ox /GL   /W3 /w44355
 -DHDF5 -D_FILE_OFFSET_BITS=64 -DH5_NO_DEPRECATED_SYMBOLS 
-DH5Gopen_vers=2 -DDLL_NEXUS -DH5_BUILT_AS_DYNAMIC_LIB 
-DDLL_EXPORT    /MD     -I. -I..\\O.Common -I. -I..\\os\\WIN32 -I..\\os\\default 
-I.. -I..\\..\\..\\include\\os\\WIN32 -I..\\..\\..\\include   
-IP:\\epics\\epics\\devel\\areaDetector-2-5\\include\\os\\WIN32 
-IP:\\epics\\epics\\devel\\areaDetector-2-5\\include 
-IP:\\epics\\epics\\base-3.14.12.5\\include\\os\\WIN32 
-IP:\\epics\\epics\\base-3.14.12.5\\include    
-IP:\\epics\\epics\\devel\\asyn-4-30\\include 
-IP:\\epics\\epics\\devel\\areaDetector-2-5\\ADSupport\\include\\os\\WIN32
-IP:\\epics\\epics\\devel\\areaDetector-2-5\\ADSupport\\include  
-IP:\\epics\\epics\\devel\\areaDetector-2-5\\ADCore\\include  
-IP:\\epics\\epics\\epicsV4\\bundleCPP\\pvCommonCPP\\include  
-IP:\\epics\\epics\\epicsV4\\bundleCPP\\pvAccessCPP\\include  
-IP:\\epics\\epics\\epicsV4\\bundleCPP\\pvDataCPP\\include  
-IP:\\epics\\epics\\epicsV4\\bundleCPP\\pvDatabaseCPP\\include  
-IP:\\epics\\epics\\epicsV4\\bundleCPP\\normativeTypesCPP\\include        
..\\stptok.c 
stptok.c
link /nologo /subsystem:windows /dll /LTCG /incremental:no /opt:ref /release        
/implib:NeXus.lib /out:NeXus.dll
 napi.obj napi5.obj napiu.obj nxdataset.obj nxio.obj nxstack.obj nxxml.obj stptok.obj       
..\\..\\..\\lib\\win32-x86\\hdf5.lib  ..\\..\\..\\lib\\win32-x86\\szip.lib  
..\\..\\..\\lib\\win32-x86\\zlib.lib
Creating library NeXus.lib and object NeXus.exp
Generating code
Finished generating code
"Installing shared library ../../../bin/win32-x86/NeXus.dll"
"Installing library ../../../lib/win32-x86/NeXus.lib"
make[1]: Leaving directory 'P:/epics/epics/devel/areaDetector-2-5/ADSupport/supportApp/nexusSrc/O.win32-x86'

So NeXus.dll links fine for me.

You should run dumpbin /exports on the hdf5.dll file and look for the symbols it is not finding for you. This is what I get

P:\epics\epics\devel\areaDetector-2-5\ADSupport\bin\win32-x86>dumpbin /exports hdf5.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file hdf5.dll

File Type: DLL

Section contains the following exports for hdf5.dll

00000000 characteristics
57F42F93 time date stamp Tue Oct 04 17:39:15 2016
    0.00 version
       1 ordinal base
    2822 number of functions
    2822 number of names

ordinal hint RVA      name

      1    0 0028B160 H5AC_BT
      2    1 0028ABD0 H5AC_BT2_HDR
      3    2 0028AC08 H5AC_BT2_INT
      4    3 0028AC40 H5AC_BT2_LEAF
      5    4 002852F0 H5AC_DRVRINFO
      6    5 00287840 H5AC_EARRAY_DBLK_PAGE
      7    6 00287808 H5AC_EARRAY_DBLOCK
...
...
   2255  8CD 002D88C8 H5T_NATIVE_SHORT_g
   2256  8CE 003B5030 H5T_NATIVE_UCHAR_ALIGN_g
   2257  8CF 002D88C0 H5T_NATIVE_UCHAR_g

Note that my hdf5.dll file contains the symbols that appear to be undefined for you, but without the leading underscore, i.e. H5T_NATIVE_SHORT_g not _H5T_NATIVE_SHORT_g. You should see if your hdf5.dll file also contains these symbols without the underscore. If it does then we need to figure out why the linker is looking for the leading underscore in your case but not in mine.

It is worth comparing versions of the compiler and linker too. Here are mine:

**P:\epics\epics\devel\areaDetector-2-5\ADSupport\bin\win32-x86>cl    
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

P:\epics\epics\devel\areaDetector-2-5\ADSupport\bin\win32-x86>link
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.
MarkRivers commented 8 years ago

I found the problem. Kevin's compile command included -DH5_BUILT_AS_STATIC_LIB, while mine had -DH5_BUILT_AS_DYNAMIC_LIB. The latter is correct, since this is the dynamic win32-x86 architecture, building a DLL. The problem was that he did not have the file areaDetector/configure/CONFIG_SITE.local.WIN32, which contains the line:

HDF5_STATIC_BUILD=$(STATIC_BUILD)

That is necessary to correctly set the -DH5_BUILT_AS_STATIC_LIB or -DH5_BUILT_AS_DYNAMIC_LIB flags when building HDF5 on Windows.