简体   繁体   中英

LDC2 -I option results in unresolved externals

I'm using the latest LDC2 beta, and when running the compiler with -I (Look for imports also in ) it fails with unresolved externals. These are my commands.

$ ldc2 "source\setup.d" -I "source" -J "build\vars" -of "build\bin\setup.exe" -m32 -g
setup.obj : error LNK2019: unresolved external symbol __D6common17createErrorDialogFxC9ExceptionZv referenced in function __Dmain
setup.obj : error LNK2019: unresolved external symbol __D6common14getConsoleArgsFxPuZAAya referenced in function __D5setup20getAvailableBrowsersFZ14__foreachbody1MFKC3std7windows8registry3KeyZi
setup.obj : error LNK2001: unresolved external symbol __D6common12__ModuleInfoZ
build\bin\setup.exe : fatal error LNK1120: 3 unresolved externals
Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\link.exe failed with status: 1120

But this next one works fine when I explicitly tell the compiler that setup.d depends on common.d .

$ ldc2 "source\setup.d" "source\common.d" -J "build\vars" -of "build\bin\setup.exe" -m32 -g

I'm using LDC2 version 1.12.0-beta2, on DMD v2.082.0, on Windows with VS Build Tools 2017. Any solutions or corrections appreciated.

Note: These compiler commands will be generated by other code, so using explicit filenames isn't feasible.

-I tells it where to find source code to import. The assumption is that the actual object code will be found in a pre-compiled library (or separate .obj files) somewhere that you pass to the linker.

If you want it to include the files in the build, using one of the newest ldc builds (as of the last couple months), it also has -i in addition to -I you can pass. -I tells it where to find the import files. -i tells it to add them to the build, instead of just treating them as an external library header.

So that's your three options:

  • compile the library separately, and add the resulting lib file to the link step
  • pass the source files all together on the command line (if it is generated by other code, just change that code to walk the directory lol)
  • get one of the latest compiler versions and add -i to the build command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM