treating as linker script

21 views Asked by At

I just set up sublime text editor for c++ but facing certain issues while compiling code. First i download msys mingw, then sublime text editor. I am not able to take input. I make three files one is file.cpp, intputf.in and outputf.out. I also build sysyem here is my code for build system

{
    "cmd": ["g++.exe", "-std=c++17", "${file}",
            "-o", "${file_base_name}.exe",
            "&&", "${file_base_name}.exe<inputf.in>outputf.out"],
    "shell":true,
    "working_dir":"$file_path",
    "selector":"source.cpp"
}

it is showing me this error

C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:C:\Users\Admin\Desktop\codeforces\inputf.in: file format not recognized; treating as linker script
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:C:\Users\Admin\Desktop\codeforces\inputf.in:1: syntax error
collect2.exe: error: ld returned 1 exit status
[Finished in 136ms]

I don't know how to resolve this

I want to fix the issue

1

There are 1 answers

0
OdatNurd On

When a build system uses $file, Sublime expands that out to the full name of the file that has the input focus/is active when you run the build.

Your build command looks correct in as much as it is trying to compile $file. turning it into an .exe file with the same base name as the input file, and then execute it.

The error message you're seeing is indicative of the compiler trying to interpret your input file as the file to compile; however it doesn't look like code and is assuming it's instructions for the linker. The linker doesn't know what to make of it either, and errors out.

Short story long: make sure that your source C/C++ file is the one that's active at the time when you trigger the build.