c++visual-studio-2010autotools

Command line error D8003 : missing source filename When linking


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.


Solution

  • 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.