Windows API: lld-link: error: undefined symbol: GetUserNameA
Today I've tried to use Windows API once again and encountered very time consuming case. It's been a long time since the last time I used Windows API. This time I've had an idea that it would be interesting to get thread associated username using Windows API. So after some time while trying to come up with something that might seemingly work. I've encountered this error: ### Error ``` C:\Users\Windows10\Desktop\interpreter>dmd WindowsGetUserName.d lld-link: error: undefined symbol: GetUserNameA referenced by WindowsGetUserName.obj:(_Dmain) Error: linker exited with status 1 ``` ### The Code ```D import std.stdio; import core.sys.windows.windows; import std.conv; void main() { char[256] userName; // Buffer to store the user name DWORD userNameSize = userName.length; // Size of the buffer // Call GetUserName to retrieve the user name if (GetUserNameA(userName.ptr, )) { // Successfully retrieved the user name writeln("Logged-in user name: ", to!string(userName[0 .. userNameSize])); } else { // Failed to retrieve the user name int error = GetLastError(); writeln("GetUserName failed with error code: ", error); } } ``` ### 1. Solution Remember to link **advapi32.lib** * `dmd WindowsGetUserName.d -Ladvapi32.lib` * `rdmd -Ladvapi32.lib WindowsGetUserName.d` ### 2. Solution Remember to include `pragma` into your source code and specify `advapi32.lib` ``` import std.stdio; import core.sys.windows.windows; import std.conv; pragma(lib, "advapi32.lib"); void main() { char[256] userName; // Buffer to store the user name DWORD userNameSize = userName.length; // Size of the buffer // Call GetUserName to retrieve the user name if (GetUserNameA(userName.ptr, )) { // Successfully retrieved the user name writeln("Logged-in user name: ", to!string(userName[0 .. userNameSize])); } else { // Failed to retrieve the user name int error = GetLastError(); writeln("GetUserName failed with error code: ", error); } } ```
Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64
On Wednesday, 3 August 2022 at 09:39:36 UTC, ryuukk_ wrote: Does adding ```-m64``` work I'm using macOS so I don't think that applies. But no, it doesn't do anything for me. Thanks, --anonymouse
Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64
Does adding ```-m64``` work
Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64
On Wednesday, 3 August 2022 at 05:04:08 UTC, H. S. Teoh wrote: On Wed, Aug 03, 2022 at 04:28:57AM +, anonymouse via Digitalmars-d-learn wrote: How do I go about tracking down what's causing the following error: ``` Undefined symbols for architecture x86_64: "__D3std8internal6memory12__ModuleInfoZ", referenced from: __D3loxQe12__ModuleInfoZ in dlux.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` I'm not explicitly calling anything in std.internal.memory so not sure how to resolve. Thanks. [...] This is often a sign of version mismatch between libraries and compiler. Did you recently upgrade your compiler? Did you accidentally install two versions of the standard library and the new compiler is mistakenly picking up the old library? Interesting... no I only have one version of DMD installed on this computer (v2.100.0) and it's never been updated. Maybe try also recompiling your project from clean slate just in case your build process is picking up stale binaries for whatever reason. If you have object files compiled with the old version of the compiler still lying around, and they get picked up when compiling with the new compiler, it would cause link errors like the above. This project aims at learning how compilers work. I'm simply adapting Robert Nystrom's code from his book [Crafting Compiler](http://www.craftinginterpreters.com/scanning.html). The source tree currently looks like this: ``` lox | + lox.d | + main.d | + scanner.d | + token.d | + tokentype.d ``` My entire build process comprises issuing the command: ``` dmd -of=dlux lox/* ``` I've tried using -J, -I, and moving main to the current working directory but all these result in the same error. --anonymouse
Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64
On Wed, Aug 03, 2022 at 04:28:57AM +, anonymouse via Digitalmars-d-learn wrote: > How do I go about tracking down what's causing the following error: > > ``` > Undefined symbols for architecture x86_64: > "__D3std8internal6memory12__ModuleInfoZ", referenced from: > __D3loxQe12__ModuleInfoZ in dlux.o > ld: symbol(s) not found for architecture x86_64 > clang: error: linker command failed with exit code 1 (use -v to see > invocation) > ``` > > I'm not explicitly calling anything in std.internal.memory so not sure > how to resolve. Thanks. [...] This is often a sign of version mismatch between libraries and compiler. Did you recently upgrade your compiler? Did you accidentally install two versions of the standard library and the new compiler is mistakenly picking up the old library? Maybe try also recompiling your project from clean slate just in case your build process is picking up stale binaries for whatever reason. If you have object files compiled with the old version of the compiler still lying around, and they get picked up when compiling with the new compiler, it would cause link errors like the above. T -- Winners never quit, quitters never win. But those who never quit AND never win are idiots.
Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64
How do I go about tracking down what's causing the following error: ``` Undefined symbols for architecture x86_64: "__D3std8internal6memory12__ModuleInfoZ", referenced from: __D3loxQe12__ModuleInfoZ in dlux.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` I'm not explicitly calling anything in std.internal.memory so not sure how to resolve. Thanks. --anonymouse
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 26 May 2022 at 16:56:49 UTC, Marcone wrote: On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote: On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I tried compiling now on x64 without console using -L/SUBSYSTEM:windows user32.lib -L/entry:mainCRTStartup -m64 and it doesn't work. It compiles, but the program does not run afterwards. I also tried to add -m32omf But in this case the compilation error. How to solve this? There is no support for OMF for x64, 64bit build is always MS-COFF. If you specify -m64 you will generate x64 MS-COFF files. If you specify -m32mscoff you will generate x86 32bit MS-COFF files. If you specify -m32omf you will generate x86 32bit OMF files. Maybe you need to clear your object files (if any) for a clean build. If you tell the linker to entry on `mainCRTStartup`, it is expected to use that function from a C-runtime linked. As the compiler is free to select a library, this is the possible error source. Try different options for `-mscrtlib=libname` switch. What do you mean by not running? Does it return an error code? (please start it in some debugger)
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote: On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it smells a litte bit that you have used OMF before. MS-COFF format inserts the reference to the C-runtime library automatically. Try the -m32omf switch. I tried compiling now on x64 without console using -L/SUBSYSTEM:windows user32.lib -L/entry:mainCRTStartup -m64 and it doesn't work. It compiles, but the program does not run afterwards. I also tried to add -m32omf But in this case the compilation error. How to solve this?
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote: On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it smells a litte bit that you have used OMF before. MS-COFF format inserts the reference to the C-runtime library automatically. Try the -m32omf switch. Now work fine! Thank you.
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it smells a litte bit that you have used OMF before. MS-COFF format inserts the reference to the C-runtime library automatically. Try the -m32omf switch.
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 22:13:06 UTC, Adam Ruppe wrote: On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote: Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ? -L/entry:mainCRTStartup try the w one too. both doing the same result? Both is doing the same result.
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote: Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ? -L/entry:mainCRTStartup try the w one too. both doing the same result?
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 20:33:34 UTC, Adam D Ruppe wrote: On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ? -L/entry:mainCRTStartup
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ?
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 19:35:20 UTC, Adam D Ruppe wrote: On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote: Using -L/SUBSYSTEM:windows user32.lib you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the build command. If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup. If using ldc instead of dmd, use -L/entry:wmainCRTStartup instead of mainCRTStartup; note the "w". see some deets i wrote here http://arsd-official.dpldocs.info/arsd.simpledisplay.html#installation-instructions I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD.
Re: Error: undefined symbol: _WinMain@16 When try compile no console
On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote: Using -L/SUBSYSTEM:windows user32.lib you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the build command. If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup. If using ldc instead of dmd, use -L/entry:wmainCRTStartup instead of mainCRTStartup; note the "w". see some deets i wrote here http://arsd-official.dpldocs.info/arsd.simpledisplay.html#installation-instructions
Error: undefined symbol: _WinMain@16 When try compile no console
Using -L/SUBSYSTEM:windows user32.lib Error: lld-link: error: undefined symbol: _WinMain@16 referenced by msvcrt120.lib(msvcrt_stub2.obj):(_WinMainCRTStartup) Error: linker exited with status 1
Re: Link error undefined symbol: __imp__InterlockedIncrement@4 on windows
On Saturday, 11 April 2020 at 05:45:37 UTC, evilrat wrote: On Thursday, 9 April 2020 at 14:07:10 UTC, Clayton Alves wrote: I'm trying to compile my first hello world dub project, but when I run "dub" it spits this error: lld-link: error: undefined symbol: __imp__InterlockedIncrement@4 Does anybody have any clues what is going on ? This is from WinAPI, a very common one https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-interlockedincrement It seems shipped version of kernel32.lib is missing that symbol. If you don't mind installing Windows SDK and build tools this is usually the way to go. On the other hand if you are specifically looking to use minimal as possible setup you could also try LDC (assuming you've been using DMD) Thank you @evilrat, After reinstalling windows SDK and build tools the error is gone.
Re: Link error undefined symbol: __imp__InterlockedIncrement@4 on windows
On Thursday, 9 April 2020 at 14:07:10 UTC, Clayton Alves wrote: I'm trying to compile my first hello world dub project, but when I run "dub" it spits this error: lld-link: error: undefined symbol: __imp__InterlockedIncrement@4 Does anybody have any clues what is going on ? This is from WinAPI, a very common one https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-interlockedincrement It seems shipped version of kernel32.lib is missing that symbol. If you don't mind installing Windows SDK and build tools this is usually the way to go. On the other hand if you are specifically looking to use minimal as possible setup you could also try LDC (assuming you've been using DMD)
Link error undefined symbol: __imp__InterlockedIncrement@4 on windows
I'm trying to compile my first hello world dub project, but when I run "dub" it spits this error: lld-link: error: undefined symbol: __imp__InterlockedIncrement@4 Does anybody have any clues what is going on ?
External .o sources + BetterC : undefined symbol: __chkstk
I got undefined symbol: __chkstk when using some external .o sources ( compile with clang ) + betterC flag. I thought that __chkstk was present on ntdll.lib, so i added manually as a lib, but still didn´t work. How can i solve this? (it must be another lib that D includes since it works without the betterC flag.)
Re: undefined symbol: _D3std7variant...
On Wednesday, 23 October 2019 at 20:45:55 UTC, baz wrote: On Tuesday, 22 October 2019 at 13:07:54 UTC, Andrey wrote: On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears again. Try the "-allinst" option. It's possibly a bug with speculative template instantiation. "-allinst" deactivates speculation and everything is always instantiated and therefore present in the object files. If `-allinst` works, then please minimize the testcase and put it in our bugtracker. We know there are template culling problems but it only appears in very complex code. I have not been able to reduce it to less than a < 20k line problem across a ton of files... -Johan
Re: undefined symbol: _D3std7variant...
On Tuesday, 22 October 2019 at 13:07:54 UTC, Andrey wrote: On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears again. Try the "-allinst" option. It's possibly a bug with speculative template instantiation. "-allinst" deactivates speculation and everything is always instantiated and therefore present in the object files.
Re: undefined symbol: _D3std7variant...
On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears again.
Re: undefined symbol: _D3std7variant...
On Tue, Oct 22, 2019 at 2:20 PM Andrey via Digitalmars-d-learn wrote: > > Hello, > During compilation on linking stage I get strange errors (LDC): > lld-link: error: undefined symbol: > _D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh4typeMxFNbNdNeZC8TypeInfo > >>> referenced by E:\Programs\LDC2\import\std\variant.d:753 > >>> > >>> .dub\obj\builder.obj:(_D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh__T4peekTQDhZQkMNgFNdZPNgAyu) > >>>referenced by > >>> E:\Programs\LDC2\import\std\variant.d:753 > >>> > >>> .dub\obj\builder.obj:(_D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh__T4peekTQBwZQkMNgFNdZPNgAAyu) > >>> referenced by > >>> E:\Programs\LDC2\import\std\variant.d:820 > >>> > >>> .dub\obj\builder.obj:(_D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh__T3getTQEdZQjMNgFNdZNgSQFxQEs__TQEmTQEjTQEjZQEy) > > How to solve? > This is the first time when linking fails on Phobos library. Have you try to clean all caches? Try to remove .dub folder
undefined symbol: _D3std7variant...
Hello, During compilation on linking stage I get strange errors (LDC): lld-link: error: undefined symbol: _D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh4typeMxFNbNdNeZC8TypeInfo referenced by E:\Programs\LDC2\import\std\variant.d:753 .dub\obj\builder.obj:(_D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh__T4peekTQDhZQkMNgFNdZPNgAyu) referenced by E:\Programs\LDC2\import\std\variant.d:753 .dub\obj\builder.obj:(_D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh__T4peekTQBwZQkMNgFNdZPNgAAyu) referenced by E:\Programs\LDC2\import\std\variant.d:820 .dub\obj\builder.obj:(_D3std7variant__T8VariantNVmi56TSQBf8typecons__T5TupleTAyuTSQCgQCf__TQCaVmi32TSQCzQBu__TQBoTAQBmTQBqZQCbTQnTQCbZQDrZQCqTQBcTQCrZQEh__T3getTQEdZQjMNgFNdZNgSQFxQEs__TQEmTQEjTQEjZQEy) How to solve? This is the first time when linking fails on Phobos library.
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Wednesday, 16 October 2019 at 15:52:22 UTC, nazriel wrote: On Friday, 11 October 2019 at 11:38:27 UTC, Jacob Carlborg wrote: ... Should we bump https://github.com/dlang/dmd/blob/master/src/posix.mak#L143 ? BR, Damian I made two PRs, lets see how it plays out: - https://github.com/dlang/dmd/pull/10489 - https://github.com/Homebrew/homebrew-core/pull/45456 BR, Damian
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Friday, 11 October 2019 at 11:38:27 UTC, Jacob Carlborg wrote: On 2019-10-10 20:12, Robert M. Münch wrote: I have two project I want to compile and both times get this error: Undefined symbols for architecture x86_64: "_dyld_enumerate_tlv_storage", referenced from: __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) I'm wondering where this comes from as I didn't see it in the past. Any idea? Any D application needs to be compiled with DMD 2.087.1 or later or the corresponding version of LDC to be able to run on macOS Catalina. That includes DMD itself. The oldest version of DMD that runs on Catalina is 2.088.0, since any given version of DMD is compiled with the previous version. That means that all D applications out there for macOS needs to be recompiled. When I tried to build DMD from source (via updated brew tap) it failed due to fact that DMD_HOST is stuck on dmd.2.079.1 which seems to still use old symbols. Should we bump https://github.com/dlang/dmd/blob/master/src/posix.mak#L143 ? BR, Damian
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Monday, 14 October 2019 at 18:49:04 UTC, Jacob Carlborg wrote: On 2019-10-14 07:36, Joel wrote: I use Home Brew (brew upgrade dmd, and brew upgrade dub) Brew is only up to 2.087.1 at the moment - John Colvin seems to be the man that mantains dmd with brew. You can use DVM [1] to install the latest version of DMD. [1] https://github.com/jacob-carlborg/dvm I added an issue for DVM under: 'macOS Cataline'
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Monday, 14 October 2019 at 18:49:04 UTC, Jacob Carlborg wrote: On 2019-10-14 07:36, Joel wrote: I use Home Brew (brew upgrade dmd, and brew upgrade dub) Brew is only up to 2.087.1 at the moment - John Colvin seems to be the man that mantains dmd with brew. You can use DVM [1] to install the latest version of DMD. [1] https://github.com/jacob-carlborg/dvm I started an issue for DVM under: 'macOS Cataline'
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Monday, 14 October 2019 at 18:49:04 UTC, Jacob Carlborg wrote: On 2019-10-14 07:36, Joel wrote: I use Home Brew (brew upgrade dmd, and brew upgrade dub) Brew is only up to 2.087.1 at the moment - John Colvin seems to be the man that mantains dmd with brew. You can use DVM [1] to install the latest version of DMD. [1] https://github.com/jacob-carlborg/dvm Thanks, but I’m not sure, since I’m using home for D, I’m not sure I won’t get complications. I guess it should be fine, I think I’ll just use TimeMachine and then try DVM.
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On 2019-10-14 09:29, Robert M. Münch wrote: => nm /usr/lib/system/libdyld.dylib | grep _dyld_enumerate_tlv_storage 00017eca T _dyld_enumerate_tlv_storage Strange, the output shows that the symbol is present. -- /Jacob Carlborg
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On 2019-10-14 07:36, Joel wrote: I use Home Brew (brew upgrade dmd, and brew upgrade dub) Brew is only up to 2.087.1 at the moment - John Colvin seems to be the man that mantains dmd with brew. You can use DVM [1] to install the latest version of DMD. [1] https://github.com/jacob-carlborg/dvm -- /Jacob Carlborg
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Monday, 14 October 2019 at 05:36:44 UTC, Joel wrote: On Friday, 11 October 2019 at 11:38:27 UTC, Jacob Carlborg wrote: [...] I get this since Catalina: Joel-Computer:VacSpace joelchristensen$ dub Failed to invoke the compiler dmd to determine the build platform: dyld: lazy symbol binding failed: Symbol not found: _dyld_enumerate_tlv_storage Referenced from: /usr/local/bin/dmd Expected in: /usr/lib/libSystem.B.dylib dyld: Symbol not found: _dyld_enumerate_tlv_storage Referenced from: /usr/local/bin/dmd Expected in: /usr/lib/libSystem.B.dylib Joel-Computer:VacSpace joelchristensen$ I use Home Brew (brew upgrade dmd, and brew upgrade dub) Brew is only up to 2.087.1 at the moment - John Colvin seems to be the man that mantains dmd with brew. I confirm that DMD downloaded from the official script works like charms on Catilina. You can rely on that right now ...
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On 2019-10-11 18:09:01 +, Jacob Carlborg said: No, I don't think that's the problem. I have the same setup and I don't have this problem. Interesting... but the update seems to have solved the problem. Maybe some old DMD compiler stuff lying around got in the way. What result do you get if you run the following command: nm /usr/lib/system/libdyld.dylib | grep _dyld_enumerate_tlv_storage => nm /usr/lib/system/libdyld.dylib | grep _dyld_enumerate_tlv_storage 00017eca T _dyld_enumerate_tlv_storage -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Friday, 11 October 2019 at 11:38:27 UTC, Jacob Carlborg wrote: On 2019-10-10 20:12, Robert M. Münch wrote: I have two project I want to compile and both times get this error: Undefined symbols for architecture x86_64: "_dyld_enumerate_tlv_storage", referenced from: __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) I'm wondering where this comes from as I didn't see it in the past. Any idea? Any D application needs to be compiled with DMD 2.087.1 or later or the corresponding version of LDC to be able to run on macOS Catalina. That includes DMD itself. The oldest version of DMD that runs on Catalina is 2.088.0, since any given version of DMD is compiled with the previous version. That means that all D applications out there for macOS needs to be recompiled. I get this since Catalina: Joel-Computer:VacSpace joelchristensen$ dub Failed to invoke the compiler dmd to determine the build platform: dyld: lazy symbol binding failed: Symbol not found: _dyld_enumerate_tlv_storage Referenced from: /usr/local/bin/dmd Expected in: /usr/lib/libSystem.B.dylib dyld: Symbol not found: _dyld_enumerate_tlv_storage Referenced from: /usr/local/bin/dmd Expected in: /usr/lib/libSystem.B.dylib Joel-Computer:VacSpace joelchristensen$ I use Home Brew (brew upgrade dmd, and brew upgrade dub) Brew is only up to 2.087.1 at the moment - John Colvin seems to be the man that mantains dmd with brew.
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On 2019-10-11 18:48, Robert M. Münch wrote: On 2019-10-10 18:31:25 +, Daniel Kozak said: What dmd version? I think I had an older one like 2.085 or so. I updated to 2.088 and it now seems to work. https://issues.dlang.org/show_bug.cgi?id=20019 I'm on OSX 10.14.6, so this might not be directly related to Catalina but maybe more to the XCode Version installed: | => xcrun --show-sdk-version 10.15 So, it's possible to run 10.14 with SDK version 10.15 which seems to trigger the problem. No, I don't think that's the problem. I have the same setup and I don't have this problem. What result do you get if you run the following command: nm /usr/lib/system/libdyld.dylib | grep _dyld_enumerate_tlv_storage -- /Jacob Carlborg
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On 2019-10-10 18:31:25 +, Daniel Kozak said: What dmd version? I think I had an older one like 2.085 or so. I updated to 2.088 and it now seems to work. https://issues.dlang.org/show_bug.cgi?id=20019 I'm on OSX 10.14.6, so this might not be directly related to Catalina but maybe more to the XCode Version installed: | => xcrun --show-sdk-version 10.15 So, it's possible to run 10.14 with SDK version 10.15 which seems to trigger the problem. Thanks for the hints. -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On 2019-10-10 20:12, Robert M. Münch wrote: I have two project I want to compile and both times get this error: Undefined symbols for architecture x86_64: "_dyld_enumerate_tlv_storage", referenced from: __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) I'm wondering where this comes from as I didn't see it in the past. Any idea? Any D application needs to be compiled with DMD 2.087.1 or later or the corresponding version of LDC to be able to run on macOS Catalina. That includes DMD itself. The oldest version of DMD that runs on Catalina is 2.088.0, since any given version of DMD is compiled with the previous version. That means that all D applications out there for macOS needs to be recompiled. -- /Jacob Carlborg
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Thursday, 10 October 2019 at 18:31:25 UTC, Daniel Kozak wrote: What dmd version? https://issues.dlang.org/show_bug.cgi?id=20019 Ah, I should have read this before replying; that's precisely the issue I had.
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
On Thursday, 10 October 2019 at 18:12:51 UTC, Robert M. Münch wrote: I have two project I want to compile and both times get this error: Undefined symbols for architecture x86_64: "_dyld_enumerate_tlv_storage", referenced from: __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) I'm wondering where this comes from as I didn't see it in the past. Any idea? I had the same missing symbol at runtime, when trying to run an already compiled binary (LDC 1.16 I think) after a Catalina update. In that case, recompiling (LDC 1.17 or DMD 2.088.0) was apparently enough to mitigate the issue.
Re: Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
What dmd version? https://issues.dlang.org/show_bug.cgi?id=20019 On Thu, Oct 10, 2019 at 8:15 PM Robert M. Münch via Digitalmars-d-learn wrote: > > I have two project I want to compile and both times get this error: > > Undefined symbols for architecture x86_64: > "_dyld_enumerate_tlv_storage", referenced from: > __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) > > I'm wondering where this comes from as I didn't see it in the past. Any idea? > > -- > Robert M. Münch > http://www.saphirion.com > smarter | better | faster >
Undefined symbol: _dyld_enumerate_tlv_storage (OSX)
I have two project I want to compile and both times get this error: Undefined symbols for architecture x86_64: "_dyld_enumerate_tlv_storage", referenced from: __d_dyld_getTLSRange in libphobos2.a(osx_tls.o) I'm wondering where this comes from as I didn't see it in the past. Any idea? -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Re: DLL creation fails with undefined symbol error
On Friday, 26 April 2019 at 05:08:32 UTC, dokutoku wrote: Is this a DUB or LDC bug? It's a combination of at least 3 small bugs in the MinGW-w64 based libraries and should be fixed by https://github.com/ldc-developers/ldc/pull/3071.
Re: DLL creation fails with undefined symbol error
fwrite, fputc - that's missing C library.
Re: DLL creation fails with undefined symbol error
On Friday, 26 April 2019 at 14:20:24 UTC, dokutoku wrote: Error: linking with LLD failed C:\ldc\bin\ldc2.exe failed with exit code 1. Ok, I have Visual Studio and SDKs installed so it works for me without touching anything else. In your case it is using lld linker instead, and I have no idea what libs it requires.
Re: DLL creation fails with undefined symbol error
On Friday, 26 April 2019 at 12:37:46 UTC, evilrat wrote: On Friday, 26 April 2019 at 05:08:32 UTC, dokutoku wrote: I tried to build a DLL in a Windows 64bit environment. It works well if the compiler is DMD, but in the case of LDC, the build fails with a large number of undefined symbol errors. Is this a DUB or LDC bug? Or do I have to specify some additional arguments to the command? Seems like DMD links some system and/or runtime libs for you, while LDC doesn't. What symbols are missing? It could be just msvcrt and some of the default system libs such as system32 and the like. There was an error like this. ``` Performing "debug" build using C:\ldc\bin\ldc2.exe for x86_64. test ~master: building configuration "library"... lld-link: error: referenced by druntime-ldc.lib(exception.obj):(_d_arrayboundsp) lld-link: error: undefined symbol: __acrt_iob_func referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: __stdio_common_vfwprintf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: __stdio_common_vfwscanf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: __stdio_common_vswprintf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN5) lld-link: error: undefined symbol: __stdio_common_vswscanf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: __stdio_common_vfprintf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: __stdio_common_vfscanf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: __stdio_common_vsprintf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN5) referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN5) lld-link: error: undefined symbol: __stdio_common_vsscanf referenced by legacy_stdio_definitions.lib(legacy_stdio_definitions.obj):($LN3) lld-link: error: undefined symbol: strlen referenced by druntime-ldc.lib(object.obj):(_D6object10ModuleInfo4nameMxFNaNbNdNiZAya) lld-link: error: undefined symbol: malloc referenced by druntime-ldc.lib(lifetime.obj):(_d_newclass) referenced by druntime-ldc.lib(lifetime.obj):(_D2rt8lifetime__T11_d_newclassVbi1ZQsFNbxC14TypeInfo_ClassZC6Object) referenced by druntime-ldc.lib(lifetime.obj):(_d_allocclass) referenced by druntime-ldc.lib(lifetime.obj):(_D2rt8lifetime__T11_d_newclassVbi0ZQsFNbxC14TypeInfo_ClassZC6Object) referenced by druntime-ldc.lib(lifetime.obj):(_D2rt8lifetime10__blkcacheFNbNdZPS4core6memory8BlkInfo_) referenced by druntime-ldc.lib(lifetime.obj):(_D2rt8lifetime12__getBlkInfoFNbPvZPS4core6memory8BlkInfo_) referenced by druntime-ldc.lib(lifetime.obj):(_D2rt8lifetime20__insertBlkInfoCacheFNbS4core6memory8BlkInfo_PQxZv) referenced by druntime-ldc.lib(lifetime.obj):(_d_arrayshrinkfit) referenced by druntime-ldc.lib(lifetime.obj):(_d_arrayshrinkfit) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetcapacity) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetcapacity) referenced by druntime-ldc.lib(lifetime.obj):(_d_delarray_t) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthiT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthiT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthiT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthiT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthiT) referenced by druntime-ldc.lib(lifetime.obj):(_d_arraysetlengthiT) referenced by druntime-ldc.lib(lifetime.obj
Re: DLL creation fails with undefined symbol error
On Friday, 26 April 2019 at 05:08:32 UTC, dokutoku wrote: I tried to build a DLL in a Windows 64bit environment. It works well if the compiler is DMD, but in the case of LDC, the build fails with a large number of undefined symbol errors. Is this a DUB or LDC bug? Or do I have to specify some additional arguments to the command? Seems like DMD links some system and/or runtime libs for you, while LDC doesn't. What symbols are missing? It could be just msvcrt and some of the default system libs such as system32 and the like.
DLL creation fails with undefined symbol error
I tried to build a DLL in a Windows 64bit environment. It works well if the compiler is DMD, but in the case of LDC, the build fails with a large number of undefined symbol errors. Is this a DUB or LDC bug? Or do I have to specify some additional arguments to the command?
Re: glfwSetDropCallback undefined symbol
23.11.2017 09:33, Tim Hsu пишет: DCD and DMD says that the symbol is undefined! However, I look into derelichtGLFW3. It has this symbol defined! It looks like a bug for me! DerelictGLFW3 has this symbol, but it does not define it, it should be defined in shared/dynamic library you use. I guess you use old version of the lib, just update it.
glfwSetDropCallback undefined symbol
DCD and DMD says that the symbol is undefined! However, I look into derelichtGLFW3. It has this symbol defined! It looks like a bug for me!
Re: Undefined symbol for, apparently, valid code?
On Thu, Jul 06, 2017 at 06:49:51PM +, unleashy via Digitalmars-d-learn wrote: > On Thursday, 6 July 2017 at 16:16:17 UTC, H. S. Teoh wrote: > > Which version of the compiler are you using? I just tested on the > > latest dmd git HEAD, and it (correctly) tells me that it's illegal > > to override a non-virtual function. I'm surprised you got your code > > to compile at all. > > `dmd --version` outputs: > > --- > DMD32 D Compiler v2.074.1 > Copyright (c) 1999-2017 by Digital Mars written by Walter Bright > --- > > I downloaded it 3 days ago, for Windows. It's not git HEAD, but it's > the one available for download in the homepage. Thankfully, it seems > fixed for the next version then? [...] Looks like it. T -- My program has no bugs! Only undocumented features...
Re: Undefined symbol for, apparently, valid code?
On Thursday, 6 July 2017 at 16:16:17 UTC, H. S. Teoh wrote: Which version of the compiler are you using? I just tested on the latest dmd git HEAD, and it (correctly) tells me that it's illegal to override a non-virtual function. I'm surprised you got your code to compile at all. `dmd --version` outputs: --- DMD32 D Compiler v2.074.1 Copyright (c) 1999-2017 by Digital Mars written by Walter Bright --- I downloaded it 3 days ago, for Windows. It's not git HEAD, but it's the one available for download in the homepage. Thankfully, it seems fixed for the next version then?
Re: Undefined symbol for, apparently, valid code?
On Thu, Jul 06, 2017 at 06:28:11AM +, unleashy via Digitalmars-d-learn wrote: > Hello. I am trying to compile this: > > --- > module asd.asd; > > abstract class Asd > { > void opCall(Args...)(Args args); > } > > @system unittest > { > class Foo : Asd > { > override void opCall(Args...)(Args args) > { > /* nothing */ > } > } > > Asd a = new Foo(); > > a(1, 2, 3); > } > --- [...] Template functions cannot be virtual, and it's invalid to override a non-virtual function. Which version of the compiler are you using? I just tested on the latest dmd git HEAD, and it (correctly) tells me that it's illegal to override a non-virtual function. I'm surprised you got your code to compile at all. T -- My program has no bugs! Only unintentional features...
Re: Undefined symbol for, apparently, valid code?
On 07/06/2017 05:11 PM, unleashy wrote: Maybe it was an error on my part for not declaring the function as abstract? My view was that the abstract attribute on a class marks all its members as virtual unless they have a body, which is how it works in, say, Java. Still, kinda odd that the linker is the one to call me out, and not the compiler. Pretty unexpected. I think an "abstract" class is only one that cannot be directly instantiated, only through a derived class. It might be "complete", though. This doesn't mean (and that's the confusion) that there couldn't be a function with a body defined in another compilation unit. In java there are no forward declarations, so there is no ambiguity here: a bodyless method means an abstract method. In D a bodyless method can mean: * An abstract method (to be provided by derived classes), which of course must then be virtual. This is indicated with the keyword "abstract". * A method whose body is provided by some other compilation unit. Of course, an abstract class without abstract methods isn't usually the intended idea... But the compiler will silently accept it and let the linker complain afterwards. Again, "final by default" to me is more confusing when anything else, specially when it's usually "virtual by default"... and it's clearly a bug that it compiles after explicitly overriding!
Re: Undefined symbol for, apparently, valid code?
On Thursday, 6 July 2017 at 06:48:57 UTC, rikki cattermole wrote: Templates+classes = require function body. Why? Templated methods are not virtual, they are final and cannot be inherited (so its a little strange that the override is valid). Ah well. I would've expected a compiler error, not an obscure linker error, but as Arafel said: Finally, have also in mind that if the function had been declared abstract (as it arguably should), a compile-time error would have been generated [2]. Maybe it was an error on my part for not declaring the function as abstract? My view was that the abstract attribute on a class marks all its members as virtual unless they have a body, which is how it works in, say, Java. Still, kinda odd that the linker is the one to call me out, and not the compiler. Pretty unexpected.
Re: Undefined symbol for, apparently, valid code?
Well, it happened to me once [1], and the reason is that templated functions are final by default (since, as you said, it doesn't make sense for them to be anything else). This way the body of the function is assumed to be in a different compilation unit (which is not, hence the linker error). If the variable had been declared of type "Foo" instead of "Asd" it would probably had worked, although this kind of defeat the purpose. Whether it makes sense that this construction is allowed, is a different question. I personally it makes sense to have the user explicitly ask for "final", since we have otherwise "virtual by default", so this behaviour is completely unexpected be most users. The whole thing makes even less sense if you take into account that a explicit request to override is just silently ignored. Finally, have also in mind that if the function had been declared abstract (as it arguably should), a compile-time error would have been generated [2]. [1]: http://forum.dlang.org/post/kgxwfsvznwzlnhrdp...@forum.dlang.org [2]: https://dpaste.dzfl.pl/22f7e0840f01 On 07/06/2017 08:48 AM, rikki cattermole wrote: > > Templates+classes = require function body. > > Why? Templated methods are not virtual, they are final and cannot be > inherited (so its a little strange that the override is valid).
Re: Undefined symbol for, apparently, valid code?
On 06/07/2017 7:28 AM, unleashy wrote: Hello. I am trying to compile this: --- module asd.asd; abstract class Asd { void opCall(Args...)(Args args); } @system unittest { class Foo : Asd { override void opCall(Args...)(Args args) { /* nothing */ } } Asd a = new Foo(); a(1, 2, 3); } --- This file is under source/asd/asd.d and I'm compiling with `dmd -unittest -main -ofasd.exe source\asd\asd.d -m32 -g` under Windows x64. For some reason, after the successful compilation step, the linker then complains: --- OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html asd.obj(asd) Error 42: Symbol Undefined _D3asd3asd3Asd17__T6opCallTiTiTiZ6opCallMFiiiZv Error: linker exited with status 1 --- Am I doing something wrong, or is this a linker bug? Thanks! Templates+classes = require function body. Why? Templated methods are not virtual, they are final and cannot be inherited (so its a little strange that the override is valid).
Undefined symbol for, apparently, valid code?
Hello. I am trying to compile this: --- module asd.asd; abstract class Asd { void opCall(Args...)(Args args); } @system unittest { class Foo : Asd { override void opCall(Args...)(Args args) { /* nothing */ } } Asd a = new Foo(); a(1, 2, 3); } --- This file is under source/asd/asd.d and I'm compiling with `dmd -unittest -main -ofasd.exe source\asd\asd.d -m32 -g` under Windows x64. For some reason, after the successful compilation step, the linker then complains: --- OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html asd.obj(asd) Error 42: Symbol Undefined _D3asd3asd3Asd17__T6opCallTiTiTiZ6opCallMFiiiZv Error: linker exited with status 1 --- Am I doing something wrong, or is this a linker bug? Thanks!
Re: Undefined symbol?
On Saturday, 21 February 2015 at 17:08:56 UTC, Joakim wrote: On Wednesday, 18 February 2015 at 08:55:51 UTC, Tofu Ninja wrote: When I compile my project in release dmd suddenly starts complains about missing symbols that look like they are from phobos. Symbol Undefined _D3std9exception134__T12errnoEnforceTbVAyaa50_433a5c445c646d64325c77696e646f77735c62696e5c2e2e5cA7E6C89DF0A958C3336C905AF5DE Any idea what is causing it and what a fix might be? See if you can reproduce with the latest 2.067 beta (http://forum.dlang.org/thread/54e41ca2.4060...@dawg.eu), and report back on the bugzilla issue that Kagamin just posted. Brian said he couldn't reproduce with the latest beta and the example there. That did in fact fix it. Will post a link to this thread in the bug report.
Re: Undefined symbol?
On Wednesday, 18 February 2015 at 08:55:51 UTC, Tofu Ninja wrote: When I compile my project in release dmd suddenly starts complains about missing symbols that look like they are from phobos. Symbol Undefined _D3std9exception134__T12errnoEnforceTbVAyaa50_433a5c445c646d64325c77696e646f77735c62696e5c2e2e5cA7E6C89DF0A958C3336C905AF5DE Any idea what is causing it and what a fix might be? See if you can reproduce with the latest 2.067 beta (http://forum.dlang.org/thread/54e41ca2.4060...@dawg.eu), and report back on the bugzilla issue that Kagamin just posted. Brian said he couldn't reproduce with the latest beta and the example there.
Re: Undefined symbol?
https://issues.dlang.org/show_bug.cgi?id=13172
Re: Undefined symbol?
On Thursday, 19 February 2015 at 01:29:39 UTC, Tofu Ninja wrote: I am not sure what could be the offending obj. I re downloaded dmd and phobos(pre compiled for windows), cleaned out all my builds and removed all of the tempfiles for dub that I could find. Have you tried running dub with --force?
Re: Undefined symbol?
On Wednesday, 18 February 2015 at 08:55:51 UTC, Tofu Ninja wrote: When I compile my project in release dmd suddenly starts complains about missing symbols that look like they are from phobos. Symbol Undefined _D3std9exception134__T12errnoEnforceTbVAyaa50_433a5c445c646d64325c77696e646f77735c62696e5c2e2e5cA7E6C89DF0A958C3336C905AF5DE Any idea what is causing it and what a fix might be? These errors are normally caused by combining object files or libraries that were compiled by different compiler versions. The biggest mistake is accidentally linking to an older/newer version of phobos.
Undefined symbol?
When I compile my project in release dmd suddenly starts complains about missing symbols that look like they are from phobos. Symbol Undefined _D3std9exception134__T12errnoEnforceTbVAyaa50_433a5c445c646d64325c77696e646f77735c62696e5c2e2e5cA7E6C89DF0A958C3336C905AF5DE Any idea what is causing it and what a fix might be?
Re: Undefined symbol?
On Wednesday, 18 February 2015 at 10:47:50 UTC, John Colvin wrote: On Wednesday, 18 February 2015 at 08:55:51 UTC, Tofu Ninja wrote: When I compile my project in release dmd suddenly starts complains about missing symbols that look like they are from phobos. Symbol Undefined _D3std9exception134__T12errnoEnforceTbVAyaa50_433a5c445c646d64325c77696e646f77735c62696e5c2e2e5cA7E6C89DF0A958C3336C905AF5DE Any idea what is causing it and what a fix might be? These errors are normally caused by combining object files or libraries that were compiled by different compiler versions. The biggest mistake is accidentally linking to an older/newer version of phobos. I am not sure what could be the offending obj. I re downloaded dmd and phobos(pre compiled for windows), cleaned out all my builds and removed all of the tempfiles for dub that I could find.
Undefined symbol ModuleInfoZ when including a SWIG generated module
Hi there, I'm currently trying to set up a small demo project using the Leap Motion API in D. I've run SWIG with -d -d2, and created the intermediate C++ DLL along with a pair of .d files, leap.d and leap_im.d. I'm new to D, but very interested and I'd like to set this up in an idiomatic way be able to share it, but I'm running into a problem: When I create a simple sample project with Visual D and import the Leap module, I get a number of linker errors: Error 42: Symbol Undefined _D4Leap10Controller6__ctorMFZC4Leap10Controller (Leap.Controller Leap.Controller.__ctor()) Error 42: Symbol Undefined _D4Leap10Controller7__ClassZ Error 42: Symbol Undefined _D4Leap12__ModuleInfoZ I've discovered that if I run dmd manually and link in the object files for leap.d and leap_im.d, these problems go away, and if I create a separate project to build a .lib and then link to that it also solves the issue. Both of these options seem hacky to me though, and I'm wondering if there's some 3rd option I'm missing - the files contain the entire definitions, so why would it be necessary to link to them AND specify them as imports? What am I missing here?
Re: Undefined symbol ModuleInfoZ when including a SWIG generated module
On Wed, 23 Apr 2014 20:34:11 -0400, Walter Gray walter.r.g...@gmail.com wrote: Hi there, I'm currently trying to set up a small demo project using the Leap Motion API in D. I've run SWIG with -d -d2, and created the intermediate C++ DLL along with a pair of .d files, leap.d and leap_im.d. I'm new to D, but very interested and I'd like to set this up in an idiomatic way be able to share it, but I'm running into a problem: When I create a simple sample project with Visual D and import the Leap module, I get a number of linker errors: Error 42: Symbol Undefined _D4Leap10Controller6__ctorMFZC4Leap10Controller (Leap.Controller Leap.Controller.__ctor()) Error 42: Symbol Undefined _D4Leap10Controller7__ClassZ Error 42: Symbol Undefined _D4Leap12__ModuleInfoZ I've discovered that if I run dmd manually and link in the object files for leap.d and leap_im.d, these problems go away, and if I create a separate project to build a .lib and then link to that it also solves the issue. Both of these options seem hacky to me though, and I'm wondering if there's some 3rd option I'm missing - the files contain the entire definitions, so why would it be necessary to link to them AND specify them as imports? What am I missing here? Every module in D generates a moduleinfo object. The runtime links all these together and uses it to run static constructors and destructors. It also contains runtime type info for any items defined within the module. Even if a module has only templates, or even if it's empty! You still have to compile and include it in the link step if it's imported from a module you are compiling. As for Visual D, I don't know much about how it works. -Steve
Re: Undefined symbol ModuleInfoZ when including a SWIG generated module
Walter Gray: the files contain the entire definitions, so why would it be necessary to link to them AND specify them as imports? What am I missing here? I don't understand why that's not regarded as a job for the compiler. But in the standard D distribution there are programs like rdmd that offer that functionality. Bye, bearophile
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 06:45:25 UTC, Tolga Cakiroglu wrote: If I don't use GCC, and use a build code as below, following is the error of compiler: dmd lib.d -shared -fPIC -debug -gc -g -w -wi /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(lifetime_46f_7db.o): relocation R_X86_64_32 against `_D15TypeInfo_Shared7__ClassZ' can not be used when making a shared object; recompile with -fPIC /usr/lib/x86_64-linux-gnu/libphobos2.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status --- errorlevel 1 make: *** [libnogcc] Error 1 http://dlang.org/dll-linux.html#dso7 dmd lib.d -shared -fPIC -debug -gc -g -w -wi -defaultlib=libphobos2.so
Re: undefined symbol: rt_finalize
http://dlang.org/dll-linux.html#dso7 dmd lib.d -shared -fPIC -debug -gc -g -w -wi -defaultlib=libphobos2.so Problem about using shared libphobos is that I need to install many different libraries on the target computer. On the web server, I don't want to install DMD. I compiled before a DLL with libphobos2.so, and on web server it started asking many different libraries which made me unhappy.
Re: undefined symbol: rt_finalize
On Thursday, 27 February 2014 at 06:25:45 UTC, Tolga Cakiroglu wrote: I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[] c = new char[ 1024 ]; destroy( objA ); destroy( c ); } makefile: -- lib: dmd -c lib.d -fPIC -debug -gc -g -w -wi gcc --shared lib.o -o lib.so After getting the `foo` symbol in the app by using dlsym, I call it, the following is output on the shell: library is loaded now Running functions... ./app: symbol lookup error: ./lib.so: undefined symbol: rt_finalize Where exactly is that function linked into an application? and why is it not linked into the library? Does it require an extra flag? because there is no finalize. rt_init/rt_term is what you need https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L30
Re: undefined symbol: rt_finalize
because there is no finalize. rt_init/rt_term is what you need https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L30 I looked at the `/usr/include/dmd/druntime` folder with `grep finalize -r`, and it brought me only one file, that is `object.di`. When I check `object.di`, I see that rt_finalize is defined as `extern(C)` and it is called in `destroy` function. Thereby, it is defined by the DMD itself. So, there is a `finalize`, but even I am not doing anything special in the code, it is not finding it while having it in a normal programme.
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 05:41:04 UTC, Tolga Cakiroglu wrote: because there is no finalize. rt_init/rt_term is what you need https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L30 I looked at the `/usr/include/dmd/druntime` folder with `grep finalize -r`, and it brought me only one file, that is `object.di`. When I check `object.di`, I see that rt_finalize is defined as `extern(C)` and it is called in `destroy` function. Thereby, it is defined by the DMD itself. So, there is a `finalize`, but even I am not doing anything special in the code, it is not finding it while having it in a normal programme. that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead.
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I believe delete() and clear() are deprecated and destroy() is the correct method. I recently read it somewhere, I'll try to find it.
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 05:59:23 UTC, Mike wrote: On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I believe delete() and clear() are deprecated and destroy() is the correct method. I recently read it somewhere, I'll try to find it. Here it is: https://github.com/D-Programming-Language/dlang.org/pull/156
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 06:02:30 UTC, Mike wrote: On Friday, 28 February 2014 at 05:59:23 UTC, Mike wrote: On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I believe delete() and clear() are deprecated and destroy() is the correct method. I recently read it somewhere, I'll try to find it. Here it is: https://github.com/D-Programming-Language/dlang.org/pull/156 It doesn't matter. `free`, `destroy`, `clear`. All of them are same. The only successful result I have found was to define `extern(C) rt_finalize2` and use it instead of destroy. It works with it, but this doesn't seem like the correct behaviour.
Re: undefined symbol: rt_finalize
that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. Nope. No chance. I have removed all imports. All `destroy`s are replaced with `clean`, and still same. I have deleted all executables and compiled again and again. ./app: symbol lookup error: ./lib.so: undefined symbol: rt_finalize I thought maybe it is not about the library but the program. But when I DO NOT call that foo function, no error is seen. That means that piece of code is making this. I have shared codes and makefile on Publink. http://publink.neffie.com/subject/ydu59u5vXyrnNKDK20yd4SDWY7iGLU1OcM7nlslAuNsPtYSM602xHMYCpKp29WU5#635291642225045068 If you are on Linux and won't bother you, can you test it please.
Re: undefined symbol: rt_finalize
On Thursday, 27 February 2014 at 06:25:45 UTC, Tolga Cakiroglu wrote: I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[] c = new char[ 1024 ]; destroy( objA ); destroy( c ); } makefile: -- lib: dmd -c lib.d -fPIC -debug -gc -g -w -wi gcc --shared lib.o -o lib.so After getting the `foo` symbol in the app by using dlsym, I call it, the following is output on the shell: library is loaded now Running functions... ./app: symbol lookup error: ./lib.so: undefined symbol: rt_finalize Where exactly is that function linked into an application? and why is it not linked into the library? Does it require an extra flag? rt_finalize is defined in lifetime.d (https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d). Its part of the D runtime. It just forwards to rt_finalize2. I don't know why you are getting an undefined symbol, though. Is the signature different?
Re: undefined symbol: rt_finalize
Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that.
Re: undefined symbol: rt_finalize
rt_finalize is defined in lifetime.d (https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d). Its part of the D runtime. It just forwards to rt_finalize2. I don't know why you are getting an undefined symbol, though. Is the signature different? I made some changes in code and culled a big part of it. Now the new error is: ./app: symbol lookup error: ./lib.so: undefined symbol: _d_newarrayiT The exact codes are below: app.d import core.sys.posix.dlfcn; void main(){ void *lh = dlopen(./lib.so, RTLD_LAZY); void function() foo = cast(void function())( dlsym( lh, foo ) ); foo(); } lib.d class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[] c = new char[ 1024 ]; clear( objA ); clear( obj ); clear( c ); } makefile all: clean lib app lib: dmd -c lib.d -fPIC -debug -gc -g -w -wi gcc --shared lib.o -o lib.so app: dmd app.d -L-ldl -L-lrt -debug -gc -g -w -wi clean: rm -f lib.so rm -f lib.o rm -f app
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that. Even Walter Bright's code doesn't use export, and goes with extern only. http://dlang.org/dll-linux.html#dso10
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 06:36:02 UTC, Tolga Cakiroglu wrote: On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that. Even Walter Bright's code doesn't use export, and goes with extern only. http://dlang.org/dll-linux.html#dso10 that articles may be outdated. export has some problems in terms it was implemented recently, and still not on all platforms. also, why are you calling gcc to make .so ? isn't dmd with -shared not works? or maybe if you really need gcc it is requires to link with phobos and/or runtime if any?
Re: undefined symbol: rt_finalize
On Friday, 28 February 2014 at 06:40:27 UTC, evilrat wrote: On Friday, 28 February 2014 at 06:36:02 UTC, Tolga Cakiroglu wrote: On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that. Even Walter Bright's code doesn't use export, and goes with extern only. http://dlang.org/dll-linux.html#dso10 that articles may be outdated. export has some problems in terms it was implemented recently, and still not on all platforms. also, why are you calling gcc to make .so ? isn't dmd with -shared not works? or maybe if you really need gcc it is requires to link with phobos and/or runtime if any? If I don't use GCC, and use a build code as below, following is the error of compiler: dmd lib.d -shared -fPIC -debug -gc -g -w -wi /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(lifetime_46f_7db.o): relocation R_X86_64_32 against `_D15TypeInfo_Shared7__ClassZ' can not be used when making a shared object; recompile with -fPIC /usr/lib/x86_64-linux-gnu/libphobos2.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status --- errorlevel 1 make: *** [libnogcc] Error 1
undefined symbol: rt_finalize
I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[] c = new char[ 1024 ]; destroy( objA ); destroy( c ); } makefile: -- lib: dmd -c lib.d -fPIC -debug -gc -g -w -wi gcc --shared lib.o -o lib.so After getting the `foo` symbol in the app by using dlsym, I call it, the following is output on the shell: library is loaded now Running functions... ./app: symbol lookup error: ./lib.so: undefined symbol: rt_finalize Where exactly is that function linked into an application? and why is it not linked into the library? Does it require an extra flag?
Associative array .length undefined symbol
Hi, I have a strange error with associative arrays. I have the following: module mod_base; abstract class Base { int[string] m_arr; } module mod_derived; class Derived : Base { void foo() { m_arr[hello] = 5; /// This works fine auto len = m_arr.length; /// Symbol error below } } I try to compile this and get: || Symbol Undefined _D6object28__T16AssociativeArrayTAyaTiZ16AssociativeArray6lengthMFNdZk| ||=== Build finished: 1 errors, 0 warnings ===| But I can still set values in the array (it still behaves like an AA). If I move the AA into the Derived class as a member, it works fine. The problem seems to be that I define Base in a separate module, which only contains this abstract class definition. If I move the abstract class definition into the same module as the Derived class, all is fine. I am just wondering why that might be? Cheers, Cal
Re: Associative array .length undefined symbol
Actually this looks like Issue 5950, missed it the first time. Maybe thats why it happens. Cal
Re: Undefined Symbol: ModuleInfo when Linking DLL Test Program
Found my own mistake: In module Test0 the import of std.stdio caused the error. There was nothing in the exports which required elements of std.stdio and somehow (don't know why) it caused ModuleInfo to be incomplete or omitted.
Undefined Symbol: ModuleInfo when Linking DLL Test Program
I am sure this a stupid mistake on my part I create a DLL Test0.dll from the following file (Test0.d): = module Test0; import std.stdio; class Test0 { export { int Test0( string ID0 ) { printf(Test0: ID={%s} ,ID0.ptr); return ID0.length+5; } } // export end } export Test0 instTest0() { return new Test0(); } = Lib listing shows the following symbols: Publics by name module _D5Test05Test05Test0MFAyaZi _D5Test05Test05Test0MFAyaZi _D5Test09instTest0FZC5Test05Test0 _D5Test09instTest0FZC5Test05Test0 Publics by module _D5Test05Test05Test0MFAyaZi _D5Test05Test05Test0MFAyaZi _D5Test09instTest0FZC5Test05Test0 _D5Test09instTest0FZC5Test05Test0 === It seems everything exported properly. I wrote the following Test Harness Test0h.d: module Test0h; import Test0; import std.stdio; int main() { Test0 t0 = instTest0(); puts(Starting main()); auto tret = t0.Test0(Harness Test0h); printf(T0 Ret=%d\n,tret); puts(Ending main()); return 0; } = with the following Import Definition file: = module Test0; import std.stdio; class Test0 { int Test0(string ID0); } Test0 instTest0(); = Watching the compile in verbose mode I get the following with the concluding error: == binaryI:\Progs\dmd2\windows\bin\dmd.exe version v2.050 configI:\Progs\dmd2\windows\bin\sc.ini parse Test0h importall Test0h importobject (I:\Progs\dmd2\windows\bin\..\..\src\druntime\import\object.di) importTest0 (Test0.di) importstd.stdio (I:\Progs\dmd2\windows\bin\..\..\src\phobos\std\stdio.d) importcore.stdc.stdio (I:\Progs\dmd2\windows\bin\..\..\src\druntime\import\core \stdc\stdio.di) .. importstd.container (I:\Progs\dmd2\windows\bin\..\..\src\phobos\std\container.d) semantic Test0h semantic2 Test0h semantic3 Test0h code Test0h function main I:\Progs\dmd2\windows\bin\link.exe Test0h,,,Test0.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 8.00.8 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html Test0h.obj(Test0h) Error 42: Symbol Undefined _D5Test012__ModuleInfoZ = I can't get the Test0 to be recognized. If I add it to the compile then of course it works, and runs properly, but that defeats the purpose of the DLL. Can someone point out my error?