How to fix " cl : Command line error D8003 : missing source filename" ?

Barath Raj M 0 Reputation points
2025-01-03T02:00:02.5766667+00:00

the output:
User's image

my project structure,

User's image

main.cpp's header is ,

#include <glad/include/glad/glad.h>

#include <glfw/include/GLFW/glfw3.h>

build.bat
https://pastebin.com/TqUTtKyP

what am i doing wrong ?
is it the slashes that interrupts the process ?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,338 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,818 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 118.9K Reputation points
    2025-01-03T02:55:33.1766667+00:00

    Try to put the linker options only after “/link”. For example:

     %COMPILER% /EHsc /O2 /std:c++17 ^
         /I"%INCLUDE_PATH%" ^
         "%SRC_DIR%\main.cpp" ^
         "%SRC_DIR%\glad.c" ^
         glfw3.lib gdi32.lib ^
         /link ^
         /LIBPATH:"%LIBRARY_PATH%" ^
         /out:"%BUILD_DIR%\test.exe"
    

    Check the documentation about the order of options.

    0 comments No comments

  2. Minxin Yu 12,351 Reputation points Microsoft Vendor
    2025-01-03T06:55:45.12+00:00

    Hi,

    LINK does not accept cpp, .c as parameters. Files should be placed after cl.

    Also check the example: The /link option and its linker options must appear after any file names and CL options.

    cl /W4 /EHsc hello.cpp there.obj /link /VERSION:3.14
    

    LINK uses the following types of input files:

    1. .obj files
    2. .netmodule files
    3. .lib files
    4. .exp files
    5. .def files
    6. .pdb files
    7. .res files
    8. .exe files
    9. .txt files
    10. .ilk files

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.