www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Linker cannot find malloc and free on OS X

reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
My gmp-d tests successfully on Linux as

dub test

but on OS X it fails as

Undefined symbols for architecture x86_64:
   "free", referenced from:
   ...
   "malloc", referenced from:
   ...

Any ideas on why?

https://github.com/nordlow/gmp-d/issues/4#issuecomment-305974761
Jun 04
next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Sunday, 4 June 2017 at 10:45:23 UTC, Nordlöw wrote:
 My gmp-d tests successfully on Linux as

 dub test

 but on OS X it fails as

 Undefined symbols for architecture x86_64:
   "free", referenced from:
   ...
   "malloc", referenced from:
   ...

 Any ideas on why?

 https://github.com/nordlow/gmp-d/issues/4#issuecomment-305974761
try giving it -lc
Jun 04
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2017-06-04 12:45, Nordlöw wrote:
 My gmp-d tests successfully on Linux as

 dub test

 but on OS X it fails as

 Undefined symbols for architecture x86_64:
   "free", referenced from:
   ...
   "malloc", referenced from:
   ...

 Any ideas on why?

 https://github.com/nordlow/gmp-d/issues/4#issuecomment-305974761
I would recommend adding the --verbose flag to see the exact commands invoked. That will print how the D compiler was invoked. The copy-paste the exact command and add the -v flag (for verbose). To the same with the C compiler and the linker. -- /Jacob Carlborg
Jun 04
parent reply bvoq <dekeyser.kevin97 gmail.com> writes:
On Sunday, 4 June 2017 at 16:13:22 UTC, Jacob Carlborg wrote:
 On 2017-06-04 12:45, Nordlöw wrote:
 My gmp-d tests successfully on Linux as

 dub test

 but on OS X it fails as

 Undefined symbols for architecture x86_64:
   "free", referenced from:
   ...
   "malloc", referenced from:
   ...

 Any ideas on why?

 https://github.com/nordlow/gmp-d/issues/4#issuecomment-305974761
I would recommend adding the --verbose flag to see the exact commands invoked. That will print how the D compiler was invoked. The copy-paste the exact command and add the -v flag (for verbose). To the same with the C compiler and the linker.
The flag -L-lc seems to have been passed to the library. This is the full error message after running it with dub test --verbose Using dub registry url 'http://code.dlang.org/' Refreshing local packages (refresh existing: true)... Looking for local package map at /var/lib/dub/packages/local-packages.json Looking for local package map at /Users/kdkdk/.dub/packages/local-packages.json Determined package version using GIT: gmp-d 0.0.3+commit.16.gedb1291 Refreshing local packages (refresh existing: false)... Looking for local package map at /var/lib/dub/packages/local-packages.json Looking for local package map at /Users/kdkdk/.dub/packages/local-packages.json Found dependency libgmp 1.0.0 Refreshing local packages (refresh existing: false)... Looking for local package map at /var/lib/dub/packages/local-packages.json Looking for local package map at /Users/kdkdk/.dub/packages/local-packages.json Found dependency libgmp 1.0.0 Checking for upgrades. Using cached upgrade results... Generating test runner configuration 'gmp-d-test-library' for 'library' (library). Get module name from path: /Users/kdkdk/Documents/psi/gmp-d/src/gmp/dbgio.d Get module name from path: /Users/kdkdk/Documents/psi/gmp-d/src/gmp/f.d Excluding package.d file from test due to https://issues.dlang.org/show_bug.cgi?id=11847 Get module name from path: /Users/kdkdk/Documents/psi/gmp-d/src/gmp/q.d Get module name from path: /Users/kdkdk/Documents/psi/gmp-d/src/gmp/traits.d Get module name from path: /Users/kdkdk/Documents/psi/gmp-d/src/gmp/z.d Refreshing local packages (refresh existing: false)... Looking for local package map at /var/lib/dub/packages/local-packages.json Looking for local package map at /Users/kdkdk/.dub/packages/local-packages.json Found dependency libgmp 1.0.0 Generate target gmp-d (executable /Users/kdkdk/Documents/psi/gmp-d gmp-d-test-library) Generate target libgmp (staticLibrary /Users/kdkdk/.dub/packages/libgmp-1.0.0/libgmp libgmp) Performing "unittest" build using dmd for x86_64. libgmp 1.0.0: target for configuration "library" is up to date. Using existing build in /Users/kdkdk/.dub/packages/libgmp-1.0.0/libgmp/.dub/build/library-unittest-posix.osx-x86_64-dmd_2074-0CBFB25E65B46672F7CAF7CC5BABCE87/. Copying target from /Users/kdkdk/.dub/packages/libgmp-1.0.0/libgmp/.dub/build/library-unittest-posix.osx-x86_64-dmd_2074-0CBFB25E65B46672F7CAF7CC BABCE87/liblibgmp.a to /Users/kdkdk/.dub/packages/libgmp-1.0.0/libgmp Target '/Users/kdkdk/Documents/psi/gmp-d/.dub/build/gmp-d-test-library-unittest-posix.osx-x86_64-dmd_2074-6A4F59B4FBEFFE587575F03F4A8B5BD0 gmp-d-test-library' doesn't exist, need rebuild. gmp-d 0.0.3+commit.16.gedb1291: building configuration "gmp-d-test-library"... Using direct -l... flags for gmp, c. dmd -c -of.dub/build/gmp-d-test-library-unittest-posix.osx-x86_64-dmd_2074-6A4F59B4FBEFFE587575F03F4A8B5BD0/ mp-d-test-library.o -debug -g -unittest -w -version=VibeCustomMain -version=Have_gmp_d -version=Have_libgmp -Isrc/ -I../../../.dub/packages/libgmp-1.0.0/libgmp/source/ ../../../../../var/folders/7s/rl2b7bj92t7c2dlnnmgzmc200000gn/T/dub_test_root-94ea7d66-86c6-4a27 9ede-42b0d74e6604.d src/gmp/dbgio.d src/gmp/f.d src/gmp/package.d src/gmp/q.d src/gmp/traits.d src/gmp/z.d -vcolumns Linking... dmd -of.dub/build/gmp-d-test-library-unittest-posix.osx-x86_64-dmd_2074-6A4F59B4FBEFFE587575F03F4A8B5BD /gmp-d-test-library .dub/build/gmp-d-test-library-unittest-posix.osx-x86_64-dmd_2074-6A4F59B4FBEFFE587575F03F4A8B5BD0/ mp-d-test-library.o ../../../.dub/packages/libgmp-1.0.0/libgmp/.dub/build/library-unittest-posix.osx-x86_64-dmd_2074-0CBFB25E65B46672F7CAF7CC BABCE87/liblibgmp.a -L-lgmp -L-lc -g Undefined symbols for architecture x86_64: "free", referenced from: _D3gmp1z3MpZ6__ctorMFNaNbNcNiNexAyakZS3gmp1z3MpZ in gmp-d-test-library.o _D3gmp1z3MpZ10fromStringMFNaNbNcNiNjNexAyakZS3gmp1z3MpZ in gmp-d-test-library.o (maybe you meant: _D2rt4util9container5treap33__T5TreapTS2gc11gcinterface4RootZ5Treap8freeNodeFNbNiPS2rt4util9container5treap33__T5TreapTS2gc11gcinterface RootZ5Treap4NodeZv, _D2gc4impl12conservative2gc3Gcx8log_freeMFNbPvZv , _D2gc4impl12conservative2gc15LargeObjectPool9freePagesMFNbmmZv , _D4core6memory2GC4freeFNaNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC163__T9runLockedS63_D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZvS37_D2gc4impl12conservative2gc8freeTimelS37_D2gc4impl12conservative2gc8numFreeslTPv 9runLockedMFNbKPvZv , _D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZv , _D2gc4impl12conservative2gc8freeTimel , _D2rt5minfo11ModuleGroup4freeMFZv , _gc_free , _D2gc4impl6manual2gc8ManualGC4freeMFNbPvZv , _D2rt7dwarfeh15ExceptionHeader4freeFPS2rt7dwarfeh15ExceptionHeaderZv , _D2rt4util9container5treap34__T5TreapTS2gc11gcinterface5RangeZ5Treap8freeNodeFNbNiPS2rt4util9container5treap34__T5TreapTS2gc11gcinterface RangeZ5Treap4NodeZv , _D2gc4impl12conservative2gc4Pool12freePageBitsMFNbmKxG4mZv , _D2gc4impl12conservative2gc14ConservativeGC4freeMFNbPvZv ) "malloc", referenced from: _D3gmp1z3MpZ19_allocStringzCopyOfMFNaNbNiNexAyaZPa in gmp-d-test-library.o (maybe you meant: _D2gc4impl12conservative2gc3Gcx10log_mallocMFNbPvmZv, _D2gc4impl6manual2gc8ManualGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC207__T9runLockedS83_D2gc4impl12conservative2gc14ConservativeGC13reallocNoSyncMFNbPvmKkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTPvTmTkTmTxC8TypeInfoZ9runLockedMFNbKPvK KkKmKxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC200__T9runLockedS79_D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTmTkTmTxC8TypeInfoZ9runLockedMFNbK KkKmKxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc10mallocTimel , _D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPv , _D4core6memory2GC6mallocFNaNbmkxC8TypeInfoZPv , _gc_malloc , _D2rt4util9container6common7xmallocFNbNimZPv ) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1 FAIL .dub/build/gmp-d-test-library-unittest-posix.osx-x86_64-dmd_2074-6A4F59B4FBEFF 587575F03F4A8B5BD0/ gmp-d-test-library executable dmd failed with exit code 1.
Jun 04
parent reply Jacob Carlborg <doob me.com> writes:
On 2017-06-05 01:14, bvoq wrote:

 The flag -L-lc seems to have been passed to the library.
 This is the full error message after running it with dub test --verbose
You need to continue to invoke the sub commands, that is, DMD, Clang and the linker with the verbose flag (-v) added. There's no point in looking for "-lc" since the C standard library on macOS is placed in /usr/lib/libSystem.B.dylib. -- /Jacob Carlborg
Jun 05
parent reply bvoq <dekeyser.kevin97 gmail.com> writes:
On Monday, 5 June 2017 at 10:34:12 UTC, Jacob Carlborg wrote:
 On 2017-06-05 01:14, bvoq wrote:

 The flag -L-lc seems to have been passed to the library.
 This is the full error message after running it with dub test 
 --verbose
You need to continue to invoke the sub commands, that is, DMD, Clang and the linker with the verbose flag (-v) added. There's no point in looking for "-lc" since the C standard library on macOS is placed in /usr/lib/libSystem.B.dylib.
So I ran: dmd -unittest -main -v -L-lgmp -L-lc -g gmp/* The error seems to stem from: cc dbgio.o -o dbgio -g -m64 -Xlinker -no_compact_unwind -lgmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm Full invocation of command with verbose flag: cc dbgio.o -o dbgio -g -m64 -Xlinker -no_compact_unwind -lgmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm -v gmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm -v Apple LLVM version 8.1.0 (clang-802.0.42) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xct olchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ sr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o dbgio -L/usr/local/Cellar/dmd/2.074.0/lib dbgio.o -no_compact_unwind -lgmp -lc -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "free", referenced from: _D3gmp1z3MpZ6__ctorMFNaNbNcNiNexAyakZS3gmp1z3MpZ in dbgio.o _D3gmp1z3MpZ10fromStringMFNaNbNcNiNjNexAyakZS3gmp1z3MpZ in dbgio.o (maybe you meant: _D2rt4util9container5treap33__T5TreapTS2gc11gcinterface4RootZ5Treap8freeNodeFNbNiPS2rt4util9container5treap33__T5TreapTS2gc11gcinterface RootZ5Treap4NodeZv, _D2gc4impl12conservative2gc3Gcx8log_freeMFNbPvZv , _D2gc4impl12conservative2gc4Pool12freePageBitsMFNbmKxG4mZv , _D2gc4impl12conservative2gc8freeTimel , _D2rt5minfo11ModuleGroup4freeMFZv , _D2gc4impl6manual2gc8ManualGC4freeMFNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC163__T9runLockedS63_D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZvS37_D2gc4impl12conservative2gc8freeTimelS37_D2gc4impl12conservative2gc8numFreeslTPv 9runLockedMFNbKPvZv , _D2rt4util9container5treap34__T5TreapTS2gc11gcinterface5RangeZ5Treap8freeNodeFNbNiPS2rt4util9container5treap34__T5TreapTS2gc11gcinterface RangeZ5Treap4NodeZv , _D2gc4impl12conservative2gc15LargeObjectPool9freePagesMFNbmmZv , _D2rt7dwarfeh15ExceptionHeader4freeFPS2rt7dwarfeh15ExceptionHeaderZv , _D2gc4impl12conservative2gc14ConservativeGC4freeMFNbPvZv , _D4core6memory2GC4freeFNaNbPvZv , _gc_free ) "malloc", referenced from: _D3gmp1z3MpZ19_allocStringzCopyOfMFNaNbNiNexAyaZPa in dbgio.o (maybe you meant: _D2gc4impl12conservative2gc3Gcx10log_mallocMFNbPvmZv, _D2gc4impl12conservative2gc10mallocTimel , _D2gc4impl6manual2gc8ManualGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC207__T9runLockedS83_D2gc4impl12conservative2gc14ConservativeGC13reallocNoSyncMFNbPvmKkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTPvTmTkTmTxC8TypeInfoZ9runLockedMFNbKPvK KkKmKxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPv , _D4core6memory2GC6mallocFNaNbmkxC8TypeInfoZPv , _gc_malloc , _D2rt4util9container6common7xmallocFNbNimZPv , _D2gc4impl12conservative2gc14ConservativeGC200__T9runLockedS79_D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTmTkTmTxC8TypeInfoZ9runLockedMFNbK KkKmKxC8TypeInfoZPv ) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) -------------------------------------- From there the command which yielded the error is: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xct olchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ sr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o dbgio -L/usr/local/Cellar/dmd/2.074.0/lib dbgio.o -no_compact_unwind -lgmp -lc -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darw n/libclang_rt.osx.a -v The output of this command: (#)PROGRAM:ld PROJECT:ld64-278.4 configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) Library search paths: /usr/local/Cellar/dmd/2.074.0/lib /usr/lib /usr/local/lib Framework search paths: /Library/Frameworks/ /System/Library/Frameworks/ Undefined symbols for architecture x86_64: "free", referenced from: _D3gmp1z3MpZ6__ctorMFNaNbNcNiNexAyakZS3gmp1z3MpZ in dbgio.o _D3gmp1z3MpZ10fromStringMFNaNbNcNiNjNexAyakZS3gmp1z3MpZ in dbgio.o (maybe you meant: _D2rt4util9container5treap33__T5TreapTS2gc11gcinterface4RootZ5Treap8freeNodeFNbNiPS2rt4util9container5treap33__T5TreapTS2gc11gcinterface RootZ5Treap4NodeZv, _D2gc4impl12conservative2gc3Gcx8log_freeMFNbPvZv , _D2gc4impl12conservative2gc4Pool12freePageBitsMFNbmKxG4mZv , _D2gc4impl12conservative2gc8freeTimel , _D2rt5minfo11ModuleGroup4freeMFZv , _D2gc4impl6manual2gc8ManualGC4freeMFNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC163__T9runLockedS63_D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZvS37_D2gc4impl12conservative2gc8freeTimelS37_D2gc4impl12conservative2gc8numFreeslTPv 9runLockedMFNbKPvZv , _D2rt4util9container5treap34__T5TreapTS2gc11gcinterface5RangeZ5Treap8freeNodeFNbNiPS2rt4util9container5treap34__T5TreapTS2gc11gcinterface RangeZ5Treap4NodeZv , _D2gc4impl12conservative2gc15LargeObjectPool9freePagesMFNbmmZv , _D2rt7dwarfeh15ExceptionHeader4freeFPS2rt7dwarfeh15ExceptionHeaderZv , _D2gc4impl12conservative2gc14ConservativeGC4freeMFNbPvZv , _D4core6memory2GC4freeFNaNbPvZv , _gc_free ) "malloc", referenced from: _D3gmp1z3MpZ19_allocStringzCopyOfMFNaNbNiNexAyaZPa in dbgio.o (maybe you meant: _D2gc4impl12conservative2gc3Gcx10log_mallocMFNbPvmZv, _D2gc4impl12conservative2gc10mallocTimel , _D2gc4impl6manual2gc8ManualGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC207__T9runLockedS83_D2gc4impl12conservative2gc14ConservativeGC13reallocNoSyncMFNbPvmKkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTPvTmTkTmTxC8TypeInfoZ9runLockedMFNbKPvK KkKmKxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPv , _D4core6memory2GC6mallocFNaNbmkxC8TypeInfoZPv , _gc_malloc , _D2rt4util9container6common7xmallocFNbNimZPv , _D2gc4impl12conservative2gc14ConservativeGC200__T9runLockedS79_D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTmTkTmTxC8TypeInfoZ9runLockedMFNbK KkKmKxC8TypeInfoZPv ) ld: symbol(s) not found for architecture x86_64 ------------------------------------- Full output of: dmd -unittest -main -v -L-lgmp -L-lc -g gmp/* predefs DigitalMars Posix OSX darwin LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC unittest assert D_HardFloat binary dmd version v2.074.0 config /usr/local/etc/dmd.conf parse dbgio parse f parse package parse q parse traits parse z parse __main importall dbgio import object (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/object.d) import core.attribute (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/attribute.d) importall f import std.algorithm.mutation (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/algorithm/mutation.d) import std.traits (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/traits.d) import std.typetuple (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/typetuple.d) import std.meta (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/meta.d) import std.range.primitives (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/range/primitives.d) import std.typecons (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/typecons.d) import core.stdc.stdint (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/stdint.d) import core.stdc.stddef (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/stddef.d) import core.stdc.signal (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/signal.d) import core.stdc.wchar_ (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/wchar_.d) import core.stdc.config (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/config.d) import core.stdc.stdarg (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/stdarg.d) import core.stdc.stdlib (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/stdlib.d) import core.stdc.stdio (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/stdio.d) import core.stdc.time (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/time.d) import core.sys.posix.sys.types (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/sys/posix/sys/types.d) import core.sys.posix.config (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/sys/posix/config.d) importall gmp importall q importall traits importall z importall __main semantic dbgio semantic f library gmp library c library gmp semantic gmp library gmp library gmp semantic q semantic traits semantic z semantic __main entry main (null) semantic2 dbgio semantic2 f semantic2 gmp semantic2 q semantic2 traits semantic2 z semantic2 __main semantic3 dbgio semantic3 f semantic3 gmp semantic3 q import std.exception (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/exception.d) import core.stdc.string (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/stdc/string.d) semantic3 traits semantic3 z import std.ascii (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/ascii.d) import std.range (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/range/package.d) import std.range.interfaces (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/range/interfaces.d) import std.array (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/array.d) import core.memory (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/memory.d) import std.functional (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/functional.d) import std.algorithm.iteration (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/std/algorithm/iteration.d) import core.internal.hash (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/internal/hash.d) import core.internal.convert (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/internal/convert.d) import core.internal.traits (/usr/local/Cellar/dmd/2.074.0/include/dlang/dmd/core/internal/traits.d) semantic3 __main code dbgio function object.dup!ubyte.dup function object._trustedDup!(const(ubyte), ubyte)._trustedDup function object._dup!(const(ubyte), ubyte)._dup function object._doPostblit!ubyte._doPostblit function object._getPostblit!ubyte._getPostblit code f code gmp code q function gmp.q.MpQ.toString function gmp.q.MpQ.toHash function gmp.q.MpQ.this function gmp.q.MpQ.canonicalize function gmp.q.MpQ.~this function gmp.q.MpQ.numerator function gmp.q.MpQ.denominator function gmp.q.MpQ.integerPart function gmp.q.MpQ.invert function gmp.q.MpQ.sgn function gmp.q.MpQ.absolute function gmp.q.MpQ.initialize function gmp.q.MpQ._ptr function gmp.q.MpQ._num_ptr function gmp.q.MpQ._den_ptr function gmp.q.MpQ.mutatingCallCount function gmp.q.MpQ.__aggrPostblit function gmp.q.MpQ.opAssign function gmp.q.MpQ.__xopEquals function gmp.q.MpQ.__xopCmp function gmp.q.__unittestL430_4 function gmp.q.__unittestL462_5 function gmp.q.__unittestL473_6 function gmp.q.__unittestL484_7 function gmp.q.__unittestL494_8 function gmp.q.__unittestL516_9 function gmp.q.__unittestL527_10 function gmp.q.__unittestL535_11 function gmp.q.__unittestL560_12 function gmp.q.__unittestL569_13 function gmp.q.__unittestL580_14 function gmp.q.__unittestL588_15 function gmp.q.__unittestL611_16 function gmp.q.__unittestL619_17 function gmp.q.__unittestL627_18 function gmp.q.__unittestL635_19 function gmp.q.MpQ.opEquals!().opEquals function gmp.q.MpQ.opEquals!().opEquals function gmp.q.MpQ.opCmp!().opCmp function gmp.q.MpQ.__ctor!(int, ulong).this function gmp.q.MpQ.__ctor!(ulong, ulong).this function gmp.q.MpQ.__ctor!double.this function gmp.q.MpQ.opAssign!double.opAssign function gmp.q.MpQ.opAssign!float.opAssign function gmp.q.MpQ.opAssign!int.opAssign function gmp.q.MpQ.__ctor!(int, int).this function gmp.q.swap!().swap function gmp.q.inverse!().inverse function gmp.q.inverse!().inverse function gmp.q.MpQ.opEquals!int.opEquals function gmp.q.abs!().abs function gmp.q.abs!().abs function gmp.q.MpQ.opCast!double.opCast function gmp.q.MpQ.opCmp!().opCmp function gmp.q.MpQ.opCmp!int.opCmp function gmp.q.MpQ.opCmp!ulong.opCmp function gmp.q.MpQ.opCmp!().opCmp function gmp.q.MpQ.opBinary!"+".opBinary function gmp.q.MpQ.opBinary!"-".opBinary function gmp.q.MpQ.opBinary!"*".opBinary function gmp.q.MpQ.opBinary!"/".opBinary code traits function gmp.traits.__unittestL28_20 function gmp.traits.__unittestL28_20.f!().f function gmp.traits.__unittestL28_20.g!().g code z function gmp.z.MpZ.toString function gmp.z.MpZ.toHash function gmp.z.MpZ.this function gmp.z.MpZ.this function gmp.z.MpZ.swap function gmp.z.MpZ.dup function gmp.z.MpZ.fromString function gmp.z.MpZ.~this function gmp.z.MpZ.toLong function gmp.z.MpZ.toInt function gmp.z.MpZ.unaryMinus function gmp.z.MpZ.negate function gmp.z.MpZ.absolute function gmp.z.MpZ.onesComplement function gmp.z.MpZ.sizeInBase function gmp.z.MpZ.populationCount function gmp.z.MpZ.setBit function gmp.z.MpZ.clearBit function gmp.z.MpZ.complementBit function gmp.z.MpZ.testBit function gmp.z.MpZ.isZero function gmp.z.MpZ.isOdd function gmp.z.MpZ.isEven function gmp.z.MpZ.isNegative function gmp.z.MpZ.isPositive function gmp.z.MpZ.sgn function gmp.z.MpZ.uintLength function gmp.z.MpZ.uintLong function gmp.z.MpZ.initialize function gmp.z.MpZ.eval function gmp.z.MpZ._limbs function gmp.z.MpZ._limbCount function gmp.z.MpZ._allocStringzCopyOf function gmp.z.MpZ._ptr function gmp.z.MpZ.__aggrPostblit function gmp.z.MpZ.__xopEquals function gmp.z.MpZ.__xopCmp function gmp.z.__unittestL1399_21 function gmp.z.__unittestL1407_22 function gmp.z.__unittestL1429_23 function gmp.z.__unittestL1464_24 function gmp.z.__unittestL2036_25 function gmp.z.__unittestL2043_26 function gmp.z.__unittestL2266_27 function gmp.z.__unittestL2289_28 function gmp.z.__unittestL2362_29 function gmp.z.__unittestL2394_30 function gmp.z.__unittestL2419_31 function gmp.z.__unittestL2445_32 function gmp.z.__unittestL2474_33 function gmp.z.__unittestL2503_34 function gmp.z.__unittestL2527_35 function gmp.z.__unittestL2547_36 function gmp.z.__unittestL2564_37 function gmp.z.MpZ.opAssign!().opAssign function gmp.z.MpZ.opEquals!().opEquals function gmp.z.MpzAddExpr!(MpZ, MpZ).MpzAddExpr.eval function gmp.z.MpzAddExpr!(MpZ, MpZ).MpzAddExpr.~this function gmp.z.MpzAddExpr!(MpZ, MpZ).MpzAddExpr.opAssign function gmp.z.MpzAddExpr!(MpZ, MpZ).MpzAddExpr.__xopEquals function gmp.z.MpzAddExpr!(MpZ, MpZ).MpzAddExpr.__xtoHash function gmp.z.MpzSubExpr!(MpZ, MpZ).MpzSubExpr.eval function gmp.z.MpzSubExpr!(MpZ, MpZ).MpzSubExpr.~this function gmp.z.MpzSubExpr!(MpZ, MpZ).MpzSubExpr.opAssign function gmp.z.MpzSubExpr!(MpZ, MpZ).MpzSubExpr.__xopEquals function gmp.z.MpzSubExpr!(MpZ, MpZ).MpzSubExpr.__xtoHash function gmp.z.MpzMulExpr!(MpZ, MpZ).MpzMulExpr.eval function gmp.z.MpzMulExpr!(MpZ, MpZ).MpzMulExpr.~this function gmp.z.MpzMulExpr!(MpZ, MpZ).MpzMulExpr.opAssign function gmp.z.MpzMulExpr!(MpZ, MpZ).MpzMulExpr.__xopEquals function gmp.z.MpzMulExpr!(MpZ, MpZ).MpzMulExpr.__xtoHash function gmp.z.MpzDivExpr!(MpZ, MpZ).MpzDivExpr.eval function gmp.z.MpzDivExpr!(MpZ, MpZ).MpzDivExpr.~this function gmp.z.MpzDivExpr!(MpZ, MpZ).MpzDivExpr.opAssign function gmp.z.MpzDivExpr!(MpZ, MpZ).MpzDivExpr.__xopEquals function gmp.z.MpzDivExpr!(MpZ, MpZ).MpzDivExpr.__xtoHash function gmp.z.MpzModExpr!(MpZ, MpZ).MpzModExpr.eval function gmp.z.MpzModExpr!(MpZ, MpZ).MpzModExpr.~this function gmp.z.MpzModExpr!(MpZ, MpZ).MpzModExpr.opAssign function gmp.z.MpzModExpr!(MpZ, MpZ).MpzModExpr.__xopEquals function gmp.z.MpzModExpr!(MpZ, MpZ).MpzModExpr.__xtoHash function gmp.z.MpzPowUExpr!(MpZ, ulong).MpzPowUExpr.eval function gmp.z.MpzPowUExpr!(MpZ, ulong).MpzPowUExpr.~this function gmp.z.MpzPowUExpr!(MpZ, ulong).MpzPowUExpr.opAssign function gmp.z.MpzPowUExpr!(MpZ, ulong).MpzPowUExpr.__xopEquals function gmp.z.MpzPowUExpr!(MpZ, ulong).MpzPowUExpr.__xtoHash function gmp.z.MpzPowMUExpr!(MpZ, ulong, MpZ).MpzPowMUExpr.eval function gmp.z.MpzPowMUExpr!(MpZ, ulong, MpZ).MpzPowMUExpr.~this function gmp.z.MpzPowMUExpr!(MpZ, ulong, MpZ).MpzPowMUExpr.opAssign function gmp.z.MpzPowMUExpr!(MpZ, ulong, MpZ).MpzPowMUExpr.__xopEquals function gmp.z.MpzPowMUExpr!(MpZ, ulong, MpZ).MpzPowMUExpr.__xtoHash function gmp.z.MpzNegExpr!(MpZ).MpzNegExpr.eval function gmp.z.MpzNegExpr!(MpZ).MpzNegExpr.~this function gmp.z.MpzNegExpr!(MpZ).MpzNegExpr.opAssign function gmp.z.MpzNegExpr!(MpZ).MpzNegExpr.__xopEquals function gmp.z.MpzNegExpr!(MpZ).MpzNegExpr.__xtoHash function gmp.z.MpZ.opBinary!"/".opBinary function gmp.z.MpZ.opEquals!int.opEquals function gmp.z.MpZ.opCmp!int.opCmp function std.algorithm.mutation.swap!(MpZ).swap function std.exception.doesPointTo!(MpZ, MpZ, void).doesPointTo function std.exception.isUnionAliasedImpl!(MpZ).isUnionAliasedImpl function std.exception.doesPointTo!(__mpz_struct, MpZ, void).doesPointTo function std.exception.isUnionAliasedImpl!(__mpz_struct).isUnionAliasedImpl function std.exception.doesPointTo!(int, MpZ, void).doesPointTo function std.exception.doesPointTo!(const(ulong)*, MpZ, void).doesPointTo function std.algorithm.mutation.swap!(MpQ).swap function std.exception.doesPointTo!(MpQ, MpQ, void).doesPointTo function std.exception.isUnionAliasedImpl!(MpQ).isUnionAliasedImpl function std.exception.doesPointTo!(__mpq_struct, MpQ, void).doesPointTo function std.exception.isUnionAliasedImpl!(__mpq_struct).isUnionAliasedImpl function std.exception.doesPointTo!(__mpz_struct, MpQ, void).doesPointTo function std.exception.doesPointTo!(int, MpQ, void).doesPointTo function std.exception.doesPointTo!(const(ulong)*, MpQ, void).doesPointTo function std.exception.doesPointTo!(ulong, MpQ, void).doesPointTo function std.algorithm.mutation.move!(MpQ).move function std.algorithm.mutation.trustedMoveImpl!(MpQ).trustedMoveImpl function std.algorithm.mutation.moveImpl!(MpQ).moveImpl function std.algorithm.mutation.moveEmplace!(MpQ).moveEmplace function gmp.z.MpZ.__ctor!int.this function std.ascii.toUpper!char.toUpper function core.internal.hash.hashOf!(const(ulong)).hashOf function core.internal.convert.toUbyte!(const(ulong)).toUbyte function gmp.z.MpZ.opCmp!long.opCmp function gmp.z._integralAbs!(const(int))._integralAbs function gmp.z.MpZ.opEquals!().opEquals function gmp.z.MpZ.opCmp!().opCmp function gmp.z.mpz!int.mpz function gmp.z.mpz!string.mpz function gmp.z.toDecimalString!().toDecimalString function gmp.z.toHex!().toHex function gmp.z.absUnsign!ulong.absUnsign function gmp.z.MpZ.opCast!ulong.opCast function gmp.z._integralAbs!ulong._integralAbs function gmp.z.MpZ.opBinary!"+".opBinary function std.algorithm.mutation.move!(MpZ).move function std.algorithm.mutation.trustedMoveImpl!(MpZ).trustedMoveImpl function std.algorithm.mutation.moveImpl!(MpZ).moveImpl function std.algorithm.mutation.moveEmplace!(MpZ).moveEmplace function gmp.z.MpZ.opBinary!"-".opBinary function gmp.z.MpZ.opBinary!"*".opBinary function gmp.z.MpZ.opBinary!"/".opBinary function gmp.z.MpZ.opBinary!"%".opBinary function gmp.z.MpZ.__ctor!uint.this function gmp.z.MpZ.__ctor!ulong.this function gmp.z.MpZ.__ctor!double.this function gmp.z.MpZ.opOpAssign!("+", ulong).opOpAssign function gmp.z.MpZ.opOpAssign!"-".opOpAssign function gmp.z.MpZ.opOpAssign!("-", ulong).opOpAssign function gmp.z.MpZ.opOpAssign!("*", ulong).opOpAssign function gmp.z.MpZ.opOpAssign!("/", ulong).opOpAssign function gmp.z.MpZ.opOpAssign!("%", ulong).opOpAssign function gmp.z.MpZ.opOpAssign!("^^", ulong).opOpAssign function gmp.z.MpZ.opAssign!int.opAssign function gmp.z.MpZ.opOpAssign!("+", int).opOpAssign function gmp.z.MpZ.opOpAssign!("-", int).opOpAssign function gmp.z.MpZ.opOpAssign!("*", int).opOpAssign function gmp.z.MpZ.opOpAssign!("/", int).opOpAssign function gmp.z.MpZ.opOpAssign!("%", int).opOpAssign function gmp.z.MpZ.opOpAssign!("^^", int).opOpAssign function gmp.z.MpZ.opAssign!double.opAssign function gmp.z.MpZ.opAssign!ulong.opAssign function gmp.z.MpZ.opOpAssign!"/".opOpAssign function gmp.z.MpZ.opUnary!"-".opUnary function gmp.z.MpZ.opOpAssign!"*".opOpAssign function gmp.z.MpZ.opOpAssign!"%".opOpAssign function gmp.z.MpZ.opEquals!uint.opEquals function gmp.z.MpZ.opEquals!long.opEquals function gmp.z.MpZ.opEquals!ulong.opEquals function gmp.z.MpZ.opEquals!float.opEquals function gmp.z.MpZ.opEquals!double.opEquals function gmp.z.MpZ.opCast!bool.opCast function gmp.z.MpZ.opCast!long.opCast function gmp.z.MpZ.opCast!double.opCast function gmp.z.MpZ.opCmp!().opCmp function gmp.z.MpZ.opCmp!uint.opCmp function gmp.z.MpZ.opCmp!ulong.opCmp function gmp.z.MpZ.opCmp!double.opCmp function gmp.z.MpZ.opUnary!"+".opUnary function gmp.z.abs!().abs function gmp.z.abs!().abs function gmp.z.cmpabs!().cmpabs function gmp.z.cmpabs!().cmpabs function gmp.z.cmpabs!().cmpabs function gmp.z.nextPrime!().nextPrime function gmp.z.nextPrime!().nextPrime function gmp.z.gcd!().gcd function gmp.z.gcd!().gcd function gmp.z.gcd!().gcd function gmp.z.gcd!().gcd function gmp.z.gcd!().gcd function gmp.z.lcm!().lcm function gmp.z.lcm!().lcm function gmp.z.lcm!().lcm function gmp.z.lcm!().lcm function gmp.z.lcm!().lcm function gmp.z.onesComplement!().onesComplement function gmp.z.onesComplement!().onesComplement function gmp.z.MpZ.opBinary!"+".opBinary function gmp.z.MpZ.opBinary!"-".opBinary function gmp.z.MpZ.opBinary!("+", int).opBinary function gmp.z.MpZ.opBinaryRight!("+", int).opBinaryRight function gmp.z.MpZ.opBinary!("+", ulong).opBinary function gmp.z.MpZ.opBinaryRight!("+", ulong).opBinaryRight function gmp.z.MpZ.opBinary!("-", int).opBinary function gmp.z.MpZ.opBinaryRight!("-", int).opBinaryRight function gmp.z.MpZ.opBinaryRight!("-", ulong).opBinaryRight function gmp.z.MpZ.opBinary!("*", ulong).opBinary function gmp.z.MpZ.opBinary!("*", int).opBinary function gmp.z.MpZ.opBinaryRight!("*", int).opBinaryRight function gmp.z.MpZ.opBinaryRight!("*", ulong).opBinaryRight function gmp.z.MpZ.opBinary!"*".opBinary function gmp.z.MpZ.opBinary!("/", int).opBinary function gmp.z.MpZ.opBinary!("/", ulong).opBinary function gmp.z.MpZ.opBinaryRight!("/", int).opBinaryRight function gmp.z.MpZ.opCast!int.opCast function gmp.z.MpZ.opBinaryRight!("/", ulong).opBinaryRight function gmp.z.MpZ.opBinary!("%", int).opBinary function gmp.z.MpZ.opBinaryRight!("%", int).opBinaryRight function gmp.z.MpZ.opBinaryRight!("%", ulong).opBinaryRight function gmp.z.MpZ.opBinary!"%".opBinary function gmp.z.MpZ.opBinary!("-", ulong).opBinary function gmp.z.MpZ.opBinaryRight!("-", long).opBinaryRight function gmp.z.MpZ.opBinary!("^^", int).opBinary function gmp.z.MpZ.opBinary!("^^", long).opBinary function gmp.z.MpZ.opBinary!("^^", ulong).opBinary function gmp.z.MpZ.pow!(ulong, ulong).pow function gmp.z.MpZ.pow!(ulong, int).pow function gmp.z.MpZ.pow!(int, int).pow function gmp.z.powm!().powm function gmp.z.powm!().powm function gmp.z.MpZ.__ctor!(immutable(int)).this function gmp.z.MpZ.opBinary!"&".opBinary function gmp.z.MpZ.opEquals!(immutable(int)).opEquals function gmp.z.MpZ.opBinary!"|".opBinary function gmp.z.MpZ.opBinary!"^".opBinary function gmp.z.MpZ.opOpAssign!"&".opOpAssign function gmp.z.MpZ.opOpAssign!"|".opOpAssign function gmp.z.MpZ.opOpAssign!"^".opOpAssign function gmp.z.swap!().swap function gmp.z.MpZ.__ctor!long.this function gmp.z.MpZ.__ctor!short.this function gmp.z.MpZ.fitsIn!short.fitsIn function gmp.z.MpZ.fitsIn!int.fitsIn function gmp.z.MpZ.fitsIn!long.fitsIn function gmp.z.MpZ.__ctor!ushort.this function gmp.z.MpZ.fitsIn!ushort.fitsIn function gmp.z.MpZ.fitsIn!uint.fitsIn function gmp.z.MpZ.fitsIn!ulong.fitsIn function gmp.z.MpZ.mersennePrime!int.mersennePrime function gmp.z.MpZ.mersennePrime!ulong.mersennePrime function gmp.z.MpZ.opOpAssign!("^^", long).opOpAssign function gmp.z.MpZ.opOpAssign!"+".opOpAssign function gmp.z.MpZ.opBinary!("%", immutable(ulong)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(uint)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(ushort)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(ubyte)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(long)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(int)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(short)).opBinary function gmp.z.MpZ.opBinary!("%", immutable(byte)).opBinary function gmp.z.MpZ.opUnary!"++".opUnary function gmp.z.MpZ.opUnary!"--".opUnary function gmp.z.MpZ.opCast!ubyte.opCast function gmp.z.MpZ.opCast!ushort.opCast function gmp.z.MpZ.opCast!uint.opCast function gmp.z.MpZ.opCast!byte.opCast function gmp.z.MpZ.opCast!short.opCast function gmp.z.MpZ.opCmp!(const(int)).opCmp function gmp.z.MpZ.mersennePrime!(immutable(ulong)).mersennePrime function gmp.z.MpZ.pow!(ulong, immutable(ulong)).pow function gmp.z.MpZ.__ctor!(immutable(ulong)).this function gmp.z.powm!().powm function gmp.z.MpZ.__ctor!(MpzAddExpr!(MpZ, MpZ)).this function gmp.z.MpZ.opAssign!(MpzAddExpr!(MpZ, MpZ)).opAssign function gmp.z.MpZ.opAssign!(MpzAddExpr!(MpZ, MpZ)).opAssign function gmp.z.MpZ.__ctor!(MpzSubExpr!(MpZ, MpZ)).this function gmp.z.MpZ.opAssign!(MpzSubExpr!(MpZ, MpZ)).opAssign function gmp.z.MpZ.__ctor!(MpzMulExpr!(MpZ, MpZ)).this function gmp.z.MpZ.opAssign!(MpzMulExpr!(MpZ, MpZ)).opAssign function gmp.z.MpZ.__ctor!(MpzDivExpr!(MpZ, MpZ)).this function gmp.z.MpZ.opAssign!(MpzDivExpr!(MpZ, MpZ)).opAssign function gmp.z.MpZ.__ctor!(MpzModExpr!(MpZ, MpZ)).this function gmp.z.MpZ.opAssign!(MpzModExpr!(MpZ, MpZ)).opAssign function gmp.z.MpZ.__ctor!(MpzNegExpr!(MpZ)).this function gmp.z.MpZ.opAssign!(MpzNegExpr!(MpZ)).opAssign code __main function D main cc dbgio.o -o dbgio -g -m64 -Xlinker -no_compact_unwind -lgmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm Undefined symbols for architecture x86_64: "free", referenced from: _D3gmp1z3MpZ6__ctorMFNaNbNcNiNexAyakZS3gmp1z3MpZ in dbgio.o _D3gmp1z3MpZ10fromStringMFNaNbNcNiNjNexAyakZS3gmp1z3MpZ in dbgio.o (maybe you meant: _D2rt4util9container5treap33__T5TreapTS2gc11gcinterface4RootZ5Treap8freeNodeFNbNiPS2rt4util9container5treap33__T5TreapTS2gc11gcinterface RootZ5Treap4NodeZv, _D2gc4impl12conservative2gc3Gcx8log_freeMFNbPvZv , _D2gc4impl12conservative2gc4Pool12freePageBitsMFNbmKxG4mZv , _D2gc4impl12conservative2gc8freeTimel , _D2rt5minfo11ModuleGroup4freeMFZv , _D2gc4impl6manual2gc8ManualGC4freeMFNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZv , _D2gc4impl12conservative2gc14ConservativeGC163__T9runLockedS63_D2gc4impl12conservative2gc14ConservativeGC10freeNoSyncMFNbPvZvS37_D2gc4impl12conservative2gc8freeTimelS37_D2gc4impl12conservative2gc8numFreeslTPv 9runLockedMFNbKPvZv , _D2rt4util9container5treap34__T5TreapTS2gc11gcinterface5RangeZ5Treap8freeNodeFNbNiPS2rt4util9container5treap34__T5TreapTS2gc11gcinterface RangeZ5Treap4NodeZv , _D2gc4impl12conservative2gc15LargeObjectPool9freePagesMFNbmmZv , _D2rt7dwarfeh15ExceptionHeader4freeFPS2rt7dwarfeh15ExceptionHeaderZv , _D2gc4impl12conservative2gc14ConservativeGC4freeMFNbPvZv , _D4core6memory2GC4freeFNaNbPvZv , _gc_free ) "malloc", referenced from: _D3gmp1z3MpZ19_allocStringzCopyOfMFNaNbNiNexAyaZPa in dbgio.o (maybe you meant: _D2gc4impl12conservative2gc3Gcx10log_mallocMFNbPvmZv, _D2gc4impl12conservative2gc10mallocTimel , _D2gc4impl6manual2gc8ManualGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC207__T9runLockedS83_D2gc4impl12conservative2gc14ConservativeGC13reallocNoSyncMFNbPvmKkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTPvTmTkTmTxC8TypeInfoZ9runLockedMFNbKPvK KkKmKxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv , _D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPv , _D4core6memory2GC6mallocFNaNbmkxC8TypeInfoZPv , _gc_malloc , _D2rt4util9container6common7xmallocFNbNimZPv , _D2gc4impl12conservative2gc14ConservativeGC200__T9runLockedS79_D2gc4impl12conservative2gc14ConservativeGC12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS40_D2gc4impl12conservative2gc10mallocTimelS40_D2gc4impl12conservative2gc10numMallocslTmTkTmTxC8TypeInfoZ9runLockedMFNbK KkKmKxC8TypeInfoZPv ) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1
Jun 05
parent Jacob Carlborg <doob me.com> writes:
On 2017-06-05 13:48, bvoq wrote:

 So I ran: dmd -unittest -main -v -L-lgmp -L-lc -g gmp/*
 The error seems to stem from: cc dbgio.o -o dbgio -g -m64 -Xlinker
 -no_compact_unwind -lgmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp
 -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm

 Full invocation of command with verbose flag: cc dbgio.o -o dbgio -g
 -m64 -Xlinker -no_compact_unwind -lgmp -lc
 -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc
 -lphobos2 -lpthread -lm -v
 gmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc
 -lphobos2 -lpthread -lm -v
 Apple LLVM version 8.1.0 (clang-802.0.42)
 Target: x86_64-apple-darwin16.7.0
 Thread model: posix
 InstalledDir:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
 -demangle -lto_library
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib
 -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o dbgio
 -L/usr/local/Cellar/dmd/2.074.0/lib dbgio.o -no_compact_unwind -lgmp -lc
 -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm -lSystem
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/libclang_rt.osx.a

 Undefined symbols for architecture x86_64:
   "free", referenced from:
       _D3gmp1z3MpZ6__ctorMFNaNbNcNiNexAyakZS3gmp1z3MpZ in dbgio.o
       _D3gmp1z3MpZ10fromStringMFNaNbNcNiNjNexAyakZS3gmp1z3MpZ in dbgio.o
I've managed to isolate and identified the problem. The problem is these two lines [1]: pragma(mangle, "malloc") void* qualifiedMalloc(size_t size); pragma(mangle, "free") void qualifiedFree(void* ptr); On macOS all C symbols are mangled with an underscore prefix, meaning the "free" and "malloc" symbols are actually named _free and _malloc in the binary. This is easy to verify by: $ cat main.c void foo(); int main() { foo(); return 0; } $ clang main.c Undefined symbols for architecture x86_64: "_foo", referenced from: _main in main-8a6861.o Here we can see that the linker is looking for the "_foo" symbol, while in your output it's looking for "free", without the underscore prefix. When pragma(mangle) is used on an extern(C) symbol the compiler will automatically handle the prefixing of the symbol on macOS, making it line up with any C symbols. Functions with D linkage have their own mangling, prefixed with _D, the fully qualified name mangled and the signature. It seems like that when using pragma(mangle) on function with D linkage the compiler will output the symbol exactly like it's specified in the source code, in pragma(mangle). This can be verified by: $ cat main.d void foo(); void main() { foo(); } $ dmd -c main.d $ nm main.o | grep foo U _D4main3fooFZv And when using pragma(mangle): $ cat main.d pragma(mangle, "foo") void foo(); void main() { foo(); } $ dmd -c main.d $ nm main.o | grep foo U foo No underscore prefix. This happens to work on Linux because on Linux this mangling (with the underscore prefix) is not used for C symbols. But since the functions are not declared as extern(C) we're actually calling C functions using the D calling conventions, which just happens to work in this case because the C and D calling conventions are mostly the same. [1] https://github.com/nordlow/gmp-d/blob/master/src/gmp/z.d#L1164-L1165 -- /Jacob Carlborg
Jun 05