www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Newbie linker errors - still missing _fltused _tls_index _tls_used

reply malpropism <propellerhead nonexistent.con> writes:
I just ported my Java application to D, got it to compile, but 
not to link.

I'm using Windows 10 64 bit, DMD 2.088.0 , Visual D 0.50.1.  This 
would be a C/C++ project in Visual Studio with only D code.

With my first attempt, I'm missing 65 externals, 328 errors.

I added these two files

ucrt.lib
vcruntime.lib

to the Additional Dependencies in the linker property pages and 
have my missing external count down to 6, 70 errors.

I'm missing the following 6 symbols:

_fltused _tls_index _tls_used localtime tzset mainCRTStartup

What other libs would I need to add to the linker's additional 
dependencies?
Sep 07 2019
next sibling parent malpropism <propellerhead nonexistent.con> writes:
PS:  Here are the actual linker errors:

1>phobos64.lib(gc_23c0_122.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(ti_float_2680_3f3.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(hash_d99_76c.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(typeinfo_2629_49b.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(demangle_c1d_79b.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(parseoptions_dbf_7cf.obj) : error LNK2001: 
unresolved external symbol _fltused
1>phobos64.lib(gc_23bb_583.obj) : error LNK2001: unresolved 
external symbol _fltused
1>dcompile_ACME.obj : error LNK2001: unresolved external symbol 
_fltused
1>phobos64.lib(ti_double_267f_3f1.obj) : error LNK2001: 
unresolved external symbol _fltused
1>phobos64.lib(hash_d90_7d1.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(hash_da7_5fe.obj) : error LNK2001: unresolved 
external symbol _fltused
1>phobos64.lib(thread_cae_681.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(thread_cb1_5f2.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23e3_142b.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(lifetime_2517_713.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(exception_c7a_fff.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(thread_cac_6f2.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23df_13c3.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23e0_687.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23e1_687.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23e2_e95.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23db_12f9.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23dc_1319.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23dd_12df.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23de_12a7.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d5_2117.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d7_1ed1.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d8_13ee.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d9_114b.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d1_10bd.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d2_12c9.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d3_12c9.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d4_1e85.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23bb_583.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23c0_122.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23cf_e95.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(gc_23d0_e95.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(advapi32_3e23_45c.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(tlsgc_25a3_1b4.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(advapi32_3e22_45a.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(sections_win64_2590_507.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(deh_win64_posix_24d8_6ee.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(thread_cd3_864.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(thread_cbe_6a3.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(registry_3d3f_4ba.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(exception_c79_d6c.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(exception_c77_1702.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(thread_c9d_48b.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(thread_c9a_713.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(profilegc.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(thread_c9c_258.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(dll.obj) : error LNK2001: unresolved external 
symbol _tls_index
1>phobos64.lib(thread_cc0_1e8.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(exception_c78_b74.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(lifetime_2515_4a3.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(profilegc_2587_424.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(concurrency_2ec9_3e4.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(lifetime_251a_7db.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(lifetime_2537_6c8.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(exception_c76_133e.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(lifetime.obj) : error LNK2001: unresolved external 
symbol _tls_index
1>dcompile_ACME.obj : error LNK2001: unresolved external symbol 
_tls_index
1>phobos64.lib(deh_win64_posix_24dd_3b9.obj) : error LNK2001: 
unresolved external symbol _tls_index
1>phobos64.lib(lifetime_2534_7cc.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>phobos64.lib(lifetime_2533_763.obj) : error LNK2001: unresolved 
external symbol _tls_index
1>LINK : error LNK2001: unresolved external symbol mainCRTStartup
1>phobos64.lib(timezone_3710_37a.obj) : error LNK2019: unresolved 
external symbol localtime referenced in function "const nothrow 
 trusted bool std.datetime.timezone.LocalTime.dstInEffect(long)" 
(_D3std8datetime8timezone9LocalTime11dstInEffectMxFNbNelZb)
1>phobos64.lib(timezone_3710_37a.obj) : error LNK2019: unresolved 
external symbol tzset referenced in function "nothrow  nogc  safe 
bool std.datetime.timezone.LocalTime.singleton().__lambda3()" 
(_D3std8datetime8timezone9LocalTime9singletonFNeZ9__lambda3FNbNiNfZb)
1>phobos64.lib(sections_win64_2590_507.obj) : error LNK2019: 
unresolved external symbol _tls_used referenced in function 
"nothrow  nogc void[] rt.sections_win64.initTLSRanges()" 
(_D2rt14sections_win6413initTLSRangesFNbNiZAv)
1>C:\Users\...\PROJECT.exe : fatal error LNK1120: 6 unresolved 
externals
Sep 07 2019
prev sibling parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 08/09/2019 00:30, malpropism wrote:
 I just ported my Java application to D, got it to compile, but not to link.
 
 I'm using Windows 10 64 bit, DMD 2.088.0 , Visual D 0.50.1.  This would
 be a C/C++ project in Visual Studio with only D code.
 
 With my first attempt, I'm missing 65 externals, 328 errors.
 
 I added these two files
 
 ucrt.lib
 vcruntime.lib
 
 to the Additional Dependencies in the linker property pages and have my
 missing external count down to 6, 70 errors.
 
 I'm missing the following 6 symbols:
 
 _fltused _tls_index _tls_used localtime tzset mainCRTStartup
 
 What other libs would I need to add to the linker's additional
 dependencies?
I suspect you have disabled the C runtime library selection in the D compilation options to build against the shared C runtime DLLs (you can select that, too). Or your code might be missing a main function in which case the selection might not be embedded into any object file. In this case, you should add msvcrt.lib instead of vcruntime.lib. Depending on used functionality you will also need legacy_stdio_definitions.lib.
Sep 08 2019
parent reply malpropism <propellerhead nonexistent.con> writes:
Thanks for very prompt reply and apologies for my extremely late 
answer.  Due to the current situation, I now have much more time 
to work on this.

In short, I upgraded to the most recent (1.20.1) LDC compiler, 
the most recent (0.52.0) Visual D, but am staying with VS 2017.

When I try to compile and link with "Release", the linker 
unresolved symbols problem goes away.  (Things which are too good 
to be true usually are)

When I try to compile and link with "Debug", I'm back to a 
similar state as before.   (429 errors, 175 unresolved externals)

I also tried adding a small .cpp file thinking it might trick the 
linker setup to add more files and libraries, I got more (455) 
errors.

When I save the linker output /VERBOSE:lib and compare the linker 
output, I have appended what stands out: (that is, missing from 
Debug yet present in Release)

----------------------------------------------------------------------------

1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\ws2_32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\wsock32.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\oldnames.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\legacy_stdio_wide_specifiers.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\vcruntime.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\ucrt\x64\ucrt.lib:


1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\shell32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\ole32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\oleaut32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\uuid.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\odbc32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\odbccp32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\ws2_32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\wsock32.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\oldnames.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\legacy_stdio_wide_specifiers.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\vcruntime.lib:

1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\ws2_32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\wsock32.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\oldnames.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\legacy_stdio_wide_specifiers.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\vcruntime.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\ucrt\x64\ucrt.lib:


1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\ws2_32.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\um\x64\wsock32.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\oldnames.lib:
2>LINK : /LTCG specified but no code generation required; remove 
/LTCG from the link command line to improve linker performance
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\legacy_stdio_wide_specifiers.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\vcruntime.lib:
1>    Searching C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.17763.0\ucrt\x64\ucrt.lib:
1>
1>Finished searching libraries
1>
1>Searching libraries
1>    Searching C:\Program Files\LDC2\lib\phobos2-ldc.lib:
1>    Searching C:\Program Files\LDC2\lib\druntime-ldc.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\legacy_stdio_definitions.lib:
1>    Searching C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64\msvcrt.lib:
Apr 26 2020
parent reply welkam <wwwelkam gmail.com> writes:
If I remember correctly VS studio has different release and debug 
configurations for both compiler and linker. If release works but 
debug doesnt make sure that when you add things to one to also 
add to another
Apr 26 2020
parent malpropism <propellerhead nonexistent.con> writes:
Thanks for your suggestion.  In VS 2017, the Property Pages have 
a configuration drop down list box which allows you select among 
Active(Debug), Debug, Release, and All Configurations.  Mine was 
set to All Configurations, leaving me to believe that setting 
something would apply to both Debug and Release.   On the surface 
it seemed to work, setting one or another parameter was felt in 
both Debug and Release.  Verbose -v compilation, for example.

Your message gave me the idea to check the .vcxproj file directly 
and sure enough, Debug and Release were (quite) different, the 
relevant offending bit of XML in the Debug linker area was

<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
Apr 26 2020