www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16096] New: Linking to static library: can't parse

https://issues.dlang.org/show_bug.cgi?id=16096

          Issue ID: 16096
           Summary: Linking to static library: can't parse
                    __DATA/__objc_imageinfo
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: freeslave93 gmail.com

I have two files. The one has Objective-C functions and interface declarations
written in D. Another file is main app and it imports the first and uses its
functions.

Imported file: http://codepad.org/jqdBb6sh
Main file: http://codepad.org/0gKBqKxi

When I compile them in one command it runs without problems.
dmd main.d domaindir.d -L-framework -LFoundation

But I want domaindir.d to be static library and link main.d against this
library. So I do:

dmd -lib domaindir.d
dmd main.d -I. -L-framework -LFoundation domaindir.a

The second command prints warning:

ld: warning: can't parse __DATA/__objc_imageinfo section in
domaindir.a(domaindir_5_397.o)

When I try to run ./main it fails:

2016-04-30 13:05:55.733 main[15762:685588] *** NSForwarding: warning: selector
(0x1040f5e58) for message 'defaultManager' does not match selector known to
Objective C runtime (0x7fff8aeed3af)-- abort
2016-04-30 13:05:55.734 main[15762:685588] +[NSFileManager defaultManager]:
unrecognized selector sent to class 0x7fff7baaad28
2016-04-30 13:05:55.736 main[15762:685588] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '+[NSFileManager
defaultManager]: unrecognized selector sent to class 0x7fff7baaad28'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff95fab03c
__exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff99ac176e
objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff95fadfad
+[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00007fff95ef3e24 ___forwarding___
+ 1028
    4   CoreFoundation                      0x00007fff95ef3998
_CF_forwarding_prep_0 + 120
    5   main                                0x00000001040baf58
D9domaindir9domainDirFNemmbZAya + 56
    6   main                                0x00000001040ba9cb _Dmain + 283
    7   main                                0x00000001040d515c
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40
    8   main                                0x00000001040d5090
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36
    9   main                                0x00000001040d5101
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 45
    10  main                                0x00000001040d5090
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36
    11  main                                0x00000001040d4ff6 _d_run_main +
498
    12  main                                0x00000001040baa80 main + 16
    13  libdyld.dylib                       0x00007fff92ee25c9 start + 1
    14  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Using dmd v2.071.0 on OS X 10.10.5

--
May 30 2016