www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18764] New: -g makes OPTLINK fail to find symbols


          Issue ID: 18764
           Summary: -g makes OPTLINK fail to find symbols
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johnnymarler gmail.com

Created attachment 1686
  --> https://issues.dlang.org/attachment.cgi?id=1686&action=edit
DirectX Library OMF Format

Optlink failed to find symbols when passing `-g` to dmd.  Note that the only
difference in the link command when passing `-g` is it adds the `/co` option to
OPTLINK (NOTE: not sure what this option means for OPTLINK).

To reproduce. clone the direct-x binding repository:

git clone https://github.com/evilrat666/directx-d

Create the following file:

--- issue.d
import directx.d2d1;

int main()
    //auto result = D2D1CreateDevice(null, null, null);
    ID2D1Factory direct2dFactory;
    auto result = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
        &IID_ID2D1Factory, &options, cast(void**)&direct2dFactory);
    return 0;

Download the attached directx omf library (converted from the COFF library).

Compilation/Link should work with the following:

dmd -I=<path-to-directx-d-repo> d2d1.omf.lib issue.d


did -I=..\directx-d\src d2d1.omf.lib issue.d

Now perform the same compilation but add `-g`, and you should get the following
linker error:

OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
 Error 42: Symbol Undefined _D2D1CreateDevice 12
 Error 42: Symbol Undefined _D2D1CreateDeviceContext 12
Error: linker exited with status 2

Apr 15 2018