digitalmars.D.learn - Real simple unresolved external symbols question...
- WhatMeWorry (29/33) Feb 09 2021 I'm trying to create a super simple dynamic library consisting of
 - Kagamin (1/1) Feb 10 2021 Add libraries that provide missing symbols.
 - Rumbu (5/39) Feb 10 2021 You have 2 obj files, and you link them. Where do you want the
 - Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (4/7) Feb 10 2021 remove /NOENTRY, and include "mixin SimpleDllMain;" in one of the
 - WhatMeWorry (8/17) Feb 10 2021 Okay, thanks. Then why does the README.md at
 - H. S. Teoh (6/13) Feb 10 2021 Probably outdated information. Somebody should submit a PR for it. ;-)
 - kinke (5/17) Feb 10 2021 It basically says there's no separate libdruntime with DMD, it's
 - Imperatorn (2/15) Feb 11 2021 Can someone in here update the docs?
 - kinke (13/28) Feb 10 2021 If you go the easy route and use LDC, everything works:
 
I'm trying to create a super simple dynamic library consisting of 
two files:
  ------------ file2.d ----------------------
extern(D):
     double addEight(double d) { return (d + 8.0); }
	
------------ fileB.d ----------------------
extern(D)
{
     string concatSuffix(string s) { return (s ~ ".ext"); }
}
dmd -m64 -c file2.d
dmd -m64 -c fileB.d
creates file2.obj and fileB.obj files
link.exe /DLL /NOENTRY file2.obj fileB.obj msvcrt.lib
fileB.obj : error LNK2019: unresolved external symbol 
_D12TypeInfo_Aya6__initZ referenced in function 
_D5fileB12concatPrefixFAyaZQe
fileB.obj : error LNK2019: unresolved external symbol 
_d_arraycatT referenced in function _D5fileB12concatPrefixFAyaZQe
Ok. I find _d_arraycatT in the D website at:
https://dlang.org/library/rt/lifetime/_d_arraycat_t.html
So I thought, this symbol will be in phobos64.lib.  But when I 
add it to the command, all hell breaks loose:
link.exe /DLL /NOENTRY file2.obj fileB.obj msvcrt.lib 
phobos64.lib
phobos64.lib(bits_23fa_21c.obj) : error LNK2001: unresolved 
external symbol memcpy
  o  o  o
file2.dll : fatal error LNK1120: 57 unresolved externals
So I'm stuck and don't have a clue as to how to continue.
I thought Phobos64.lib was self-contained.  Do I need to add 
other libraries?  And how do I know which ones?
 Feb 09 2021
On Tuesday, 9 February 2021 at 19:37:17 UTC, WhatMeWorry wrote:
 I'm trying to create a super simple dynamic library consisting 
 of two files:
  ------------ file2.d ----------------------
 extern(D):
     double addEight(double d) { return (d + 8.0); }
 	
 ------------ fileB.d ----------------------
 extern(D)
 {
     string concatSuffix(string s) { return (s ~ ".ext"); }
 }
dmd -m64 -c file2.d
dmd -m64 -c fileB.d
 creates file2.obj and fileB.obj files
 link.exe /DLL /NOENTRY file2.obj fileB.obj msvcrt.lib
 fileB.obj : error LNK2019: unresolved external symbol 
 _D12TypeInfo_Aya6__initZ referenced in function 
 _D5fileB12concatPrefixFAyaZQe
 fileB.obj : error LNK2019: unresolved external symbol 
 _d_arraycatT referenced in function 
 _D5fileB12concatPrefixFAyaZQe
 Ok. I find _d_arraycatT in the D website at:
 https://dlang.org/library/rt/lifetime/_d_arraycat_t.html
 So I thought, this symbol will be in phobos64.lib.  But when I 
 add it to the command, all hell breaks loose:
link.exe /DLL /NOENTRY file2.obj fileB.obj msvcrt.lib 
phobos64.lib
 phobos64.lib(bits_23fa_21c.obj) : error LNK2001: unresolved 
 external symbol memcpy
  o  o  o
 file2.dll : fatal error LNK1120: 57 unresolved externals
 So I'm stuck and don't have a clue as to how to continue.
 I thought Phobos64.lib was self-contained.  Do I need to add 
 other libraries?  And how do I know which ones?
You have 2 obj files, and you link them. Where do you want the 
"self contained" to be present?
The missing symbols in your case are in druntime.lib, not in 
phobos.
 Feb 10 2021
On Tuesday, 9 February 2021 at 19:37:17 UTC, WhatMeWorry wrote:I'm trying to create a super simple dynamic library consisting of two files: [...]remove /NOENTRY, and include "mixin SimpleDllMain;" in one of the sources. And link with druntime. link /DLL file2.obj fileB.obj druntime-ldc.lib msvcrt.lib
 Feb 10 2021
On Wednesday, 10 February 2021 at 11:38:00 UTC, Ferhat Kurtulmuş wrote:On Tuesday, 9 February 2021 at 19:37:17 UTC, WhatMeWorry wrote:Okay, thanks. Then why does the README.md at https://github.com/dlang/druntime say "Runtime is typically linked together with Phobos in a release such that the compiler only has to link to a single library to provide the user with the runtime and the standard library."I'm trying to create a super simple dynamic library consisting of two files: [...]remove /NOENTRY, and include "mixin SimpleDllMain;" in one of the sources. And link with druntime. link /DLL file2.obj fileB.obj druntime-ldc.lib msvcrt.lib
 Feb 10 2021
On Wed, Feb 10, 2021 at 11:35:27PM +0000, WhatMeWorry via Digitalmars-d-learn wrote: [...]Okay, thanks. Then why does the README.md at https://github.com/dlang/druntime say "Runtime is typically linked together with Phobos in a release such that the compiler only has to link to a single library to provide the user with the runtime and the standard library."Probably outdated information. Somebody should submit a PR for it. ;-) T -- Let X be the set not defined by this sentence...
 Feb 10 2021
On Thursday, 11 February 2021 at 00:18:23 UTC, H. S. Teoh wrote:On Wed, Feb 10, 2021 at 11:35:27PM +0000, WhatMeWorry via Digitalmars-d-learn wrote: [...]It basically says there's no separate libdruntime with DMD, it's included in libphobos2 (unlike LDC). So 'runtime' in the context of the druntime repo is 'druntime', not 'C runtime and other platform libs' libphobos/druntime depend on.Okay, thanks. Then why does the README.md at https://github.com/dlang/druntime say "Runtime is typically linked together with Phobos in a release such that the compiler only has to link to a single library to provide the user with the runtime and the standard library."Probably outdated information. Somebody should submit a PR for it. ;-)
 Feb 10 2021
On Thursday, 11 February 2021 at 00:18:23 UTC, H. S. Teoh wrote:On Wed, Feb 10, 2021 at 11:35:27PM +0000, WhatMeWorry via Digitalmars-d-learn wrote: [...]Can someone in here update the docs?Okay, thanks. Then why does the README.md at https://github.com/dlang/druntime say "Runtime is typically linked together with Phobos in a release such that the compiler only has to link to a single library to provide the user with the runtime and the standard library."Probably outdated information. Somebody should submit a PR for it. ;-) T
 Feb 11 2021
On Tuesday, 9 February 2021 at 19:37:17 UTC, WhatMeWorry wrote:
 I'm trying to create a super simple dynamic library consisting 
 of two files:
  ------------ file2.d ----------------------
 extern(D):
     double addEight(double d) { return (d + 8.0); }
 	
 ------------ fileB.d ----------------------
 extern(D)
 {
     string concatSuffix(string s) { return (s ~ ".ext"); }
 }
dmd -m64 -c file2.d
dmd -m64 -c fileB.d
 creates file2.obj and fileB.obj files
 link.exe /DLL /NOENTRY file2.obj fileB.obj msvcrt.lib
If you go the easy route and use LDC, everything works:
ldc2 -shared file1.d file2.d
=> file1.dll
Or, if you really prefer separate compile + link:
ldc2 -c file1.d
ldc2 -c file2.d
ldc2 -shared file1.obj file2.obj
Use `-v` to see what the actual link.exe cmdline is, and notice 
the MSVC and Windows libs that are implicitly added. - IIRC, DMD 
only embeds these system libs into the object file containing 
main/DllMain (and you have none), whereas LDC adds them to the 
linker cmdline.
 Feb 10 2021








 
 
 
 Kagamin <spam here.lot> 