Linux no input files

Error in makefile («no input files»)

This is my absolute first time ever making a makefile, and I’m really trying to understand the process. I’m trying to create a very simple makefile for a C++ project whose structure is as follows: root folder
makefile
readme
src folder
. source files all here.
include folder
. header files for external libraries here.
lib folder
. external lib files all here.
bin folder
. output directory for built executable.
obj folder
. object files all here.
I followed the tutorial here. Here’s my makefile:

IDIR=include . CC=g++ CFLAGS=-I$(IDIR) ODIR=bin/obj LDIR=lib LIBS=none SRC=src _DEPS=hello.h DEPS=$(patsubst %,$(IDIR)/,%(_DEPS)) _OBJ=file1.o file2.o OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ)) $(ODIR)/%.o: $(SRC)/%.cpp $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) # $(LIBS) test_proj: $(OBJ) $(CC) -o $@ $^ $(CFLAGS) .PHONY: clean clean: rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ 
g++ -o .o g++: fatal error: no input files compilation terminated. : recipe for target '.o' failed mingw32-make.exe: *** [.o] Error 1 

I'm using GNU Make 3.82.90 built for i686-pc-mingw32, if that matters at all. Can anyone point out whatever ridiculous error I'm making?

Honestly, I agree it's overkill and I've scaled this down to a working and simpler makefile. Part of my goal with this project was to decouple myself for Windows / Visual Studio and gain confidence in the GNU toolchain and workflow. The project will likely grow, but I wanted to make sure I could build a makefile that would work on a project with a more complicated structure, so I started with this for my simple project. So yeah, overkill 🙂

Working on it 🙂 Working on Windows = a temporary condition; I just really wanted to get started on this.

2 Answers 2

is the first problem. Replace it by:

With your code CFLAGS is expanded as:

It does not make sense, I'm afraid. The second problem is:

if you fix the first problem, else as:

which does not make sense neither. The cumulated effect of these two errors are strange recipes (I didn't try to expand them by hand) that probably trigger a make implicit rule with wrong parameters.

IDIR=include . CC=g++ CFLAGS=-I$(IDIR) 

This is wrong. First, for C++ code, use CXX not CC and CXXFLAGS not CFLAGS . Run make -p to understand the builtin rules of your make .

Then -I$(IDIR) does not "distribute" the -I , and IDIR is never used elsewhere. So I suggest to start your Makefile with:

CXX=g++ MY_CXX_LANG_FLAGS= -std=c++11 MY_CXX_WARN_FLAGS= -Wall -Wextra MY_CXX_INCL_FLAGS= -I. -Iinclude MY_CXX_MACRO_FLAGS= -DMYFOO=32 ### replace with -O2 for a release build below MY_CXX_OPTIM_FLAGS= -g CXXFLAGS= $(MY_CXX_LANG_FLAGS) $(MY_CXX_WARN_FLAGS) \ $(MY_CXX_INCL_FLAGS) $(MY_CXX_MACRO_FLAGS) 

I won't improve your Makefile , but I do suggest to upgrade to GNU make version 4 if possible (and compiling make 4.1 from its source code is worthwhile in 2015) for that purpose. If possible enable GUILE scripting in it.

If you are forced to use make 3.82 debug your Makefile using remake (with -x ); if you can afford a make version 4 use its --trace option

BTW, you might consider using automatic dependencies, that is generating dependencies by passing -M or -MG (etc) flags of g++ , see that.

Читайте также:  Forwarding linux что это

At last, a simple project for a small program (less than a hundred thousands of source lines) might just put all (a few dozens of) its files in the current directory (then the Makefile could be simpler); your proposed directory structure might be arcane for a simple project (but could worth the pain if you have millions of C++ source lines of code). I've given several simple examples of Makefile , e.g. this & that. And GNU make source code itself has a less complex file tree that what you want.

BTW, I strongly disagree with the opinions of that answer (which I did upvote, since it is helpful). I don't feel that GNU make is senile, but I regret that, instead of using recent features available on recent versions (4.x) of make , many people prefer to use complex and arcane Makefile generators (like cmake ) instead of coding a clever Makefile (for make version 4 specifically).

At last, you could use other builders, e.g. omake, icmake , .

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g++: fatal error: no input files #243

g++: fatal error: no input files #243

Comments

I am trying to compile and run a simple hello world c++ code. g++ says no input files:

g++: fatal error: no input files
compilation terminated.

It seems that the g++ is not running in the same directory which c++ file is placed or maybe file path is not correct in compilation command. How to solve the problem?

The text was updated successfully, but these errors were encountered:

I have the same problem when I run "g++ --version";

g++ (MinGW.org GCC-8.2.0-3) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

in my terminal i am trying to run a welcome.cpp file that's code is

# include
using namespace std;
int main()
cout >> "Hello What's your name "
char name = ""
cin char msg = "Hello " + name + ". Nice to meet you!"
cout >> msg >> endl
cout >> "" >> endl
>

and when I type "g++ -o welcome.cpp" then enter this is what comes up

Screenshot from 2019-06-08 12-18-01

for one, your code will not compile, you have multiple fatal errors in your code.
#include is not used, is necessary for cout.
cout doesn't use >>, but you miss ; in your code, c and c++ do need this to work.

addressing the fatal error.
You can compile and run it from the UNIX prompt as follows :
% g++ welcome.cpp
This creates an executable called "a.out". You can run it by typing
% ./a.out
Since no executable name was specified to g++, a.out is chosen by default. Use the "-o" option to change the name :
% g++ -o welcome welcome.cpp
creates an executable called "welcome".

Читайте также:  Виджеты для astra linux

me the same and when I run code again it announce Code is already running!

in my terminal i am trying to run a welcome.cpp file that's code is

include

Screenshot from 2019-06-08 12-18-01

using namespace std;
int main()
cout >> "Hello What's your name "
char name = ""
cin char msg = "Hello " + name + ". Nice to meet you!"
cout >> msg >> endl
cout >> "" >> endl
>

and when I type "g++ -o welcome.cpp" then enter this is what comes up

I got the same mistake. That's funny.

Just go with "g++ -o welcome welcome.cpp"

@rishiamalhotra

for one, your code will not compile, you have multiple fatal errors in your code.
#include is not used, is necessary for cout.
cout doesn't use >>, but you miss ; in your code, c and c++ do need this to work.

addressing the fatal error.
You can compile and run it from the UNIX prompt as follows :
% g++ welcome.cpp
This creates an executable called "a.out". You can run it by typing
% ./a.out
Since no executable name was specified to g++, a.out is chosen by default. Use the "-o" option to change the name :
% g++ -o welcome welcome.cpp
creates an executable called "welcome".

Thanks a lot. My issue is solved now. The file is working for me now.

Don't use name file with space, u must be used underline

Don't use name file with space, u must be used underline

Thank you 👍 My issue is solved now

I had the same problem, I was trying to compile had the same error, test to see if you have installed:-
~$ gcc --version
~$ g++ --version
~$ clang --version
~$ gdb --version
and set the path

make sure that the path of the file you are running not have any white spaces

i have a same issue too
#include
int soChuSo(int n) if(n==0)
return 0;
return 1+soChuSo(n/10);
>

int tongChuSo(int n) if(n>0)
return n%10+tongChuSo(n/10);
return 0;
>

image

int main() int n;
printf("Nhap so nguyen n: ");
scanf("%d",&n);
printf("So n co %d chu so\n",soChuSo(n));
printf("Tong cac chu so cua n la: %d\n",tongChuSo(n));
return 0;
>

Источник

Thread: [SOLVED] gcc: no input files

ms2756 is offline5 Cups of Ubuntu

Question[SOLVED] gcc: no input files

I have spent a decent amount of time trying to get my gcc to work, but it won't. Here's what I tried:

sudo apt-get install gcc
//told me I had the latest version

gcc -o HelloWorld.c
gcc: no input files

gcc -Wall -ansi HelloWorld.c
//a bunch of stuff, like
HelloWorld.c:7: error: 'cout' undeclared (first use in this function)

I also used Tab to complete program name, so there are no errors of that sort. Also gcc complained at some point about not recognizing

Here is my program (copied directly from a book):

Thank you very much for any suggestions.
Side note: I have Ubuntu 8.10, installed it yesterday, so should be up to date.

igknighted is offlineUbuntu addict and loving it

Re: gcc: no input files

gcc -o file.c will try to output a file called file.c, and no input file was given. You would probably want 'gcc file.c -o file.bin', which would input the file file.c, and output the file file.bin

EDIT: replace those first two lines in your file with '#include '

What book are you using? That's some pretty odd looking C code.

EDIT #2: You might need some additional libraries to compile. try installing the package build-essential too

Desktop: AMD Athlon64 X2 3600+, Nvidia 8600GT, 3GB RAM, 80GB hd, Windows 7 Beta
Lappy: Sony Vaio FW-140E, Intel P8400 2.26Ghz, 3GB Ram, 250GB HD, Intel x4500MHD, Windows 7 Beta & Kubuntu 8.10 w/ KDE 4.2

Читайте также:  Cyberpunk 2077 для linux

anewguy is offline

I Ubuntu, Therefore, I Am

Join Date Jun 2007 Location Sometimes I visit earth Beans 5,435 --> Beans 5,435 Distro Ubuntu 12.04 Precise Pangolin

WinkRe: gcc: no input files

I'm trying to remember, but isn't cout a C++ function? If so, have you tried using g++ in place of gcc?

MighMoS is offlineGee! These Aren't Roasted!

Re: gcc: no input files

QuoteOriginally Posted by ms2756 View Post

I have spent a decent amount of time trying to get my gcc to work, but it won't. Here's what I tried:

sudo apt-get install gcc
//told me I had the latest version

gcc -o HelloWorld.c
gcc: no input files

gcc -Wall -ansi HelloWorld.c
//a bunch of stuff, like
HelloWorld.c:7: error: 'cout' undeclared (first use in this function)

I also used Tab to complete program name, so there are no errors of that sort. Also gcc complained at some point about not recognizing

Here is my program (copied directly from a book):

You need g++. Also, you have a .c extension, which the compiler will assume to be C (not C++). Using .cc or .cpp is recommended, instead. So in the end your command to compile and run your program will look something like

g++ HelloWorld.cc -o HelloWorld ./HelloWorld

What I love about Linux: everything is just one command away. Just use && liberally.

Источник

How to fix ‘Clang: Error: No input files’?

Programming has come a long way from its early Assembly days. Now we have a lot of different programming languages to choose from, each with its difficulties and pros and cons.

However, that’s not to say you’ll get through writing code without hitting any snags. In this article, we’re talking about the “clang: error: no input files” issue that you might face with C++ and how to fix the problem.

Run the xcode installer

The first thing you should do is run the xcode-select installer. It’ll download and set up any file you might need to run clang. Run the following command in the terminal, and you’re good to go.

xcode-select -- install

Check the file directory

Before you can run your script, your terminal needs to be in the same directory as your script itself. You can either navigate to the folder, right-click and open a terminal, or use the cd command to navigate the folder tree inside the terminal.

What is Metadata? Types and benefits | Candid.Technology

Regardless, once you’re in the same directory as the script, try running it, and it should work just fine, provided there were no other bugs in the code.

Point to xcode

Sometimes your computer might not know where Xcode is installed even after installing the package. In such cases, you can manually point to your Xcode installation using the following command.

sudo xcode-select --switch /Applications/Xcode.app

Specify the GCC version

Sometimes the compiler might be unable to find a file to compile using GCC. In such cases, you will have to specify the GCC version installed on your machine manually. To find the GCC version, run the following command in the terminal.

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: [email protected]

Источник

Оцените статью
Adblock
detector