Build with hdfeos2 fails due to -fPIC warning, but library was built with -fPIC
captainkirk99 opened this issue · 5 comments
Building without HDFEOS2 works fine.
Building with it gives this -fPIC error message. However, I'm sure that the HDFEOS library I'm pointing to was built with -fPIC. Also @jgallagher59701 reported this to me as well, but I thought it was because he was pointing to a non-relocatable library. But perhaps not...
/bin/bash ../../libtool --tag=CXX --mode=link g++ -I../../hdfclass -g -O2 --pedantic --std=c++11 -avoid-version -module -o libhdf4_module.la -rpath /usr/local/bes-3.20.7/lib/bes hdfeos.tab.lo lex.hdfeos.lo HDFArray.lo HDFGrid.lo HDFSequence.lo HDFUInt32.lo HDFByte.lo HDFInt16.lo HDFStr.lo HDFUrl.lo HDFFloat32.lo HDFInt32.lo HDFStructure.lo HDFFloat64.lo HDFUInt16.lo HDFTypeFactory.lo HDFCFUtil.lo BESH4MCache.lo HDFCFStr.lo HDFEOS2.lo HDFEOS2CFStr.lo HDFSP.lo HDFSPArrayGeoField.lo HDFSPArrayAddCVField.lo HDFSPArrayMissField.lo HDFSPArray_RealField.lo HDFSPArray_VDField.lo HDFCFStrField.lo HDFEOS2CFStrField.lo HDFEOS2Array_RealField.lo HDFEOS2ArrayGridGeoField.lo HDFEOS2ArraySwathGeoField.lo HDFEOS2ArrayMissField.lo HDFEOS2ArraySwathDimMapField.lo HDFEOS2ArraySwathGeoDimMapExtraField.lo HDFEOS2ArraySwathGeoMultiDimMapField.lo HDFEOS2GeoCFProj.lo HDFEOS2GeoCF1D.lo HE2CF.lo misr_init.lo misrinv.lo dhdferr.lo hdfdesc.lo hc2dap.lo hdfutil.lo HDF4RequestHandler.lo HDF4Module.lo hdfclass/libhdfclass.la -L/usr/local/hdfeos2.19_fPIC/lib -lhdfeos -lGctp -lmfhdf -ldf -ljpeg -lz -lsz -ldapserver -ldap -ldapclient -ldap -lcurl -luuid
libtool: link: g++ -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o .libs/hdfeos.tab.o .libs/lex.hdfeos.o .libs/HDFArray.o .libs/HDFGrid.o .libs/HDFSequence.o .libs/HDFUInt32.o .libs/HDFByte.o .libs/HDFInt16.o .libs/HDFStr.o .libs/HDFUrl.o .libs/HDFFloat32.o .libs/HDFInt32.o .libs/HDFStructure.o .libs/HDFFloat64.o .libs/HDFUInt16.o .libs/HDFTypeFactory.o .libs/HDFCFUtil.o .libs/BESH4MCache.o .libs/HDFCFStr.o .libs/HDFEOS2.o .libs/HDFEOS2CFStr.o .libs/HDFSP.o .libs/HDFSPArrayGeoField.o .libs/HDFSPArrayAddCVField.o .libs/HDFSPArrayMissField.o .libs/HDFSPArray_RealField.o .libs/HDFSPArray_VDField.o .libs/HDFCFStrField.o .libs/HDFEOS2CFStrField.o .libs/HDFEOS2Array_RealField.o .libs/HDFEOS2ArrayGridGeoField.o .libs/HDFEOS2ArraySwathGeoField.o .libs/HDFEOS2ArrayMissField.o .libs/HDFEOS2ArraySwathDimMapField.o .libs/HDFEOS2ArraySwathGeoDimMapExtraField.o .libs/HDFEOS2ArraySwathGeoMultiDimMapField.o .libs/HDFEOS2GeoCFProj.o .libs/HDFEOS2GeoCF1D.o .libs/HE2CF.o .libs/misr_init.o .libs/misrinv.o .libs/dhdferr.o .libs/hdfdesc.o .libs/hc2dap.o .libs/hdfutil.o .libs/HDF4RequestHandler.o .libs/HDF4Module.o -Wl,--whole-archive hdfclass/.libs/libhdfclass.a -Wl,--no-whole-archive -L/usr/local/hdf-4.2.15_fPIC/lib -L/usr/local/hdfeos2.19_fPIC/lib /usr/local/hdfeos2.19_fPIC/lib/libhdfeos.a /usr/local/hdfeos2.19_fPIC/lib/libGctp.a /usr/local/hdf-4.2.15_fPIC/lib/libmfhdf.a /usr/local/hdf-4.2.15_fPIC/lib/libdf.a /home/ed/hyrax/build/deps/lib/libmfhdf.a -L/home/ed/hyrax/build/deps/lib /home/ed/hyrax/build/deps/lib/libdf.a -ljpeg -lz -lsz -ldapserver -ldapclient -ldap /usr/lib/x86_64-linux-gnu/libcurl.so -luuid -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o -g -O2 -pthread -Wl,-soname -Wl,libhdf4_module.so -o .libs/libhdf4_module.so
/usr/bin/ld: /usr/local/hdfeos2.19_fPIC/lib/libhdfeos.a(EHapi.o): relocation R_X86_64_PC32 against symbol `EHXtypeTable' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:750: libhdf4_module.la] Error 1
make[4]: Leaving directory '/home/ed/bes/modules/hdf4_handler'
make[3]: *** [Makefile:888: all-recursive] Error 1
make[3]: Leaving directory '/home/ed/bes/modules/hdf4_handler'
make[2]: *** [Makefile:504: all-recursive] Error 1
make[2]: Leaving directory '/home/ed/bes/modules'
make[1]: *** [Makefile:759: all-recursive] Error 1
make[1]: Leaving directory '/home/ed/bes'
make: *** [Makefile:542: all] Error 2
According to this StackOverflow post, the following indicates that the library was built with -fPIC: https://stackoverflow.com/questions/1340402/how-can-i-tell-with-something-like-objdump-if-an-object-file-has-been-built-wi
(base) ed@mikado:~/bes$ readelf --relocs /usr/local/hdfeos2.19_fPIC/lib/libhdfeos.a | egrep '(GOT|PLT|JU?MP_SLOT)'
00000000012f 00a400000004 R_X86_64_PLT32 0000000000000000 Hfidinquire - 4
00000000013c 00a500000004 R_X86_64_PLT32 0000000000000000 strcmp - 4
00000000015d 00a600000004 R_X86_64_PLT32 0000000000000000 HEpush - 4
00000000016e 00a700000004 R_X86_64_PLT32 0000000000000000 HEreport - 4
000000000193 00a800000004 R_X86_64_PLT32 0000000000000000 Hopen - 4
0000000001ad 00a900000004 R_X86_64_PLT32 0000000000000000 SDstart - 4
0000000001c0 00aa00000004 R_X86_64_PLT32 0000000000000000 Vinitialize - 4
000000000272 00a800000004 R_X86_64_PLT32 0000000000000000 Hopen - 4
00000000028a 00a900000004 R_X86_64_PLT32 0000000000000000 SDstart - 4
0000000002a4 00ac00000004 R_X86_64_PLT32 0000000000000000 SDfindattr - 4
0000000002c1 00ac00000004 R_X86_64_PLT32 0000000000000000 SDfindattr - 4
0000000002dc 00ad00000004 R_X86_64_PLT32 0000000000000000 calloc - 4
0000000003ab 00ae00000004 R_X86_64_PLT32 0000000000000000 SDsetattr - 4
0000000003b3 00af00000004 R_X86_64_PLT32 0000000000000000 free - 4
0000000003c1 00b000000004 R_X86_64_PLT32 0000000000000000 __errno_location - 4
000000000402 00a600000004 R_X86_64_PLT32 0000000000000000 HEpush - 4
00000000041f 00b100000004 R_X86_64_PLT32 0000000000000000 __stpcpy_chk - 4
00000000043d 00b200000004 R_X86_64_PLT32 0000000000000000 __memcpy_chk - 4
00000000045c 00b200000004 R_X86_64_PLT32 0000000000000000 __memcpy_chk - 4
00000000046d 00a700000004 R_X86_64_PLT32 0000000000000000 HEreport - 4
000000000477 00b000000004 R_X86_64_PLT32 0000000000000000 __errno_location - 4
0000000004b5 00a600000004 R_X86_64_PLT32 0000000000000000 HEpush - 4
0000000004ec 00b300000004 R_X86_64_PLT32 0000000000000000 __sprintf_chk - 4
0000000004fd 00a700000004 R_X86_64_PLT32 0000000000000000 HEreport - 4
000000000521 00a600000004 R_X86_64_PLT32 0000000000000000 HEpush - 4
00000000053d 00a700000004 R_X86_64_PLT32 0000000000000000 HEreport - 4
00000000056a 00a600000004 R_X86_64_PLT32 0000000000000000 HEpush - 4
000000000585 00a700000004 R_X86_64_PLT32 0000000000000000 HEreport - 4
000000000597 00a900000004 R_X86_64_PLT32 0000000000000000 SDstart - 4
0000000005d1 00b300000004 R_X86_64_PLT32 0000000000000000 __sprintf_chk - 4
000000000623 00ae00000004 R_X86_64_PLT32 0000000000000000 SDsetattr - 4
000000000632 00a800000004 R_X86_64_PLT32 0000000000000000 Hopen - 4
000000000643 00ad00000004 R_X86_64_PLT32 0000000000000000 calloc - 4
000000000720 00ae00000004 R_X86_64_PLT32 0000000000000000 SDsetattr - 4
000000000728 00af00000004 R_X86_64_PLT32 0000000000000000 free - 4
00000000074f 00a600000004 R_X86_64_PLT32 0000000000000000 HEpush - 4
...
OK, I have another install of hdfeos, and I have the config.log for the build, and it shows:
$ ./configure --prefix=/usr/local/hdfeos_fPIC --enable-install-include
and
CFLAGS='-fPIC'
CPP='gcc -E'
CPPFLAGS='-I/usr/local/hdf-4.2.15_fPIC/include'
CXX='g++'
CXXCPP='g++ -E'
CXXDEPMODE='depmode=gcc3'
CXXFLAGS='-g -O2'
Build is happening now...
Well I think that might have worked. How odd! However, it fails in another way:
HDFEOS2.cc: In static member function ‘static HDFEOS2::File* HDFEOS2::File::Read(const char*, int32, int32)’:
HDFEOS2.cc:171:52: error: invalid conversion from ‘int32 (*)(const char*, char*, int32*)’ {aka ‘int (*)(const char*, char*, int*)’} to ‘int32 (*)(char*, char*, int32*)’ {aka ‘int (*)(char*, char*, int*)’} [-fpermissive]
171 | if (!Utility::ReadNamelist(file->path.c_str(), SWinqswath, swathlist)){
| ^~~~~~~~~~
| |
| int32 (*)(const char*, char*, int32*) {aka int (*)(const char*, char*, int*)}
This could be the version difference between the two hdfeos versions. I will recompile with the -fpermisive flag and see what happens...
This is similar to SpatioTemporal/STAREmaster#111.
OK, this build now works with the -fpermissive flag set.