Command line error D8003 : missing source filename When linking

10,453

Solution 1

Microsoft's C/C++ compiler can pass options to the linker via the '/link' command or by commands known as Compiler-Controlled LINK Options.

The '/Fe' option is thus equivalent to '/link /OUT:'. This definitely solves the problem.

Alternatively, the order of the flags can fix the issue. By changing this:

/link /OUT:AverageFilter.mexw32 AverageFilter.obj

To this:

AverageFilter.obj /link /OUT:AverageFilter.mexw32

The linker is called correctly.

Solution 2

Just ran into this error during compilation. For me it was because the compiler couldn't deal with a trailing slash.

/external:I "$(WindowsSdkDir)"

expanded to

/external:I "C:\Program Files (x86)\Windows Kits\10\"

which triggered the error. Appending a dot fixed it for me:

/external:I "$(WindowsSdkDir)."

Solution 3

for my particular case, in the c++ project properties -> general -> command line

i had the options /I "$(OutDir)" /I ".."

and i had to change this into

/I "($(OutDir))" /I ".."

Share:
10,453
Daeden
Author by

Daeden

Graduate student at USC.

Updated on July 26, 2022

Comments

  • Daeden
    Daeden almost 2 years

    I'm using Autotools to compile Matlab modules. Originally, we used Libtool to accomplish, but it really does a terrible job dealing with Microsoft's compilers. As such, we are removing Libtool for Windows builds.

    Here is some information that might be useful:

    $ cl /V
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    $ uname -a
    CYGWIN_NT-6.1 RatTop 1.7.18(0.263/5/3) 2013-04-19 10:39 i686 Cygwin
    

    Unfortunately, I am having a linking error that I cannot explain:

    CXXLD    AverageFilter.mexw32
    cl  /DTRILIBRARY /DANSI_DECLARATORS /DNO_TIMER /D_HAVE_MATLAB_MODULES_ /D_GNU_SOURCE -O2 -DWIN32 -D_INTEL_WIN_ -EHsc /link /OUT:AverageFilter.mexw32 AverageFilter.obj /DLL /export:mexFunction /link /LIBPATH:"C:/root/extern/lib/win32/microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /INCREMENTAL:NO /manifest ./libISSMMatlab.a ../../c/libISSMModules.a ../../c/libISSMCore.a C:/root/home/Daeden/issm/trunk-jpl/externalpackages/petsc/install/lib/libpetsc.lib /link /LIBPATH:"C:/root/home/Daeden/issm/trunk-jpl/externalpackages/petsc/install/lib" libpetsc.lib /nologo
    cl : Command line error D8003 : missing source filename
    Makefile:860: recipe for target `AverageFilter.mexw32' failed
    

    Can anyone explain how to get rid of this error? It would make sense if I was trying to compile, but I'm only trying to link.

  • sclarke81
    sclarke81 over 5 years
    I just had exactly the same problem/solution. Do you know why this works?