Bug 15148 – Linker error with packages

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2015-10-03T21:03:26Z
Last change time
2023-06-28T12:11:53Z
Assigned to
No Owner
Creator
yazan.dabain

Comments

Comment #0 by yazan.dabain — 2015-10-03T21:03:26Z
File structure: app.d p/package.d ----- app.d ----- import p; void main() { a(); } ----- p/package.d ----- void a() {} ------------------------ Compiling using `dmd app.d p/package.d` succeeds except for the linker failing with: app.o: In function `_Dmain': p/package.d:(.text._Dmain+0x5): undefined reference to `_D1p1aFZv' collect2: error: ld returned 1 exit status --- errorlevel 1 ------------------------ Tested with 2.068.2 and 2.067.1.
Comment #1 by dlang-bugzilla — 2015-10-15T19:14:01Z
package.d needs a module statement, it doesn't know where the hierarchy root is. I think this is invalid.
Comment #2 by yazan.dabain — 2015-10-15T19:38:36Z
I think it should either be a compilation error or it should just work, but not a linker error. I don't have a preference to either.
Comment #3 by razvan.nitu1305 — 2023-06-28T12:11:53Z
This now fails with: ``` app.d(5): Error: undefined identifier `a` ``` So it is no longer an error.