C++ Make asks for a file that doesn't exist - c++

When I try to build/compile my code, I get this error:
make: *** No rule to make target '../../Source/GardenCounter.cpp', needed by 'build/intermediate/Debug/GardenCounter_15332182.o'. Stop.
The terminal process "/bin/bash '-c', 'make QUIET=0'" terminated with exit code: 2.
I don't have a file named GardenCounter.cpp anymore. I deleted it and yet it is still asking for it. I tried to delete the old .o and .d files and recompile everything from scratch but I'm still being asked for this.

Probably it would help to post your Makefile here. Without it, it's hard to know what the specific issue is. But here are some things to try off the top of my head:
-Look for the name of that source file in your Makefile. Did you remove it from all the build dependencies there?
-Is there a wildcard expression used somewhere in your Makefile that might be picking up that name from some other file? Possibly a header or an intermediate build file?

Related

Add source to an existing automake program

I would like to edit an existing software to add a new source file (Source.cpp).
But, I can't manage the compilation process (it seems to be automake and it looks very complicated).
The software (iperf 2: https://sourceforge.net/projects/iperf2/files/?source=navbar) is compiled using a classical ./configure make then make install.
If I just add the file to the corresponding source and include directory, I got this error message:
Settings.cpp:(.text+0x969) : undefined reference to ...
It looks like the makefile isn't able to produce the output file associated with my new source file (Source.cpp). So, I probably need to indicate it manually somewhere.
I searched a bit in the project files and it seemed that the file to edit was: "Makefile.am".
I added my source to the variable iperf_SOURCES in that file but it didn't workded.
Could you help me to find the file where I need to indicate my new source file (it seems a pretty standard compilation scheme but I never used automake softwares and this one seems very complicated).
Thank you in advance
This project is built with the autotools, as you already figured out.
The makefiles are built by automake. It takes its input in files that usually have a am file name extension.
The iperf program is built by the makefile generated from src/Makefile.am. This is indicated by:
bin_PROGRAMS = iperf
All (actually this is a simplification, but which holds in this case) source files of a to be built binary are in the corresponding name_SOURCES variable, thus in this case iperf_SOURCES. Just add your source file to the end of that list, like so (keeping their formatting):
iperf_SOURCES = \
Client.cpp \
# lines omitted
tcp_window_size.c \
my_new_file.c
Now, to reflect this change in any future generated src/Makefile you need to run automake. This will modify src/Makefile.in, which is a template that is used by config.sub at the end of configure to generate the actual makefile.
Running automake can happen in various ways:
If you already have makefiles that were generated after an configure these should take care of rebuilding themselves. This seems to fail sometimes though!
You could run automake (in the top level directory) by hand. I've never done this, as there is the better solution to...
Run autoreconf --install (possibly add --force to the arguments) in the top level directory. This will regenerate the entire build system, calling all needed programs such as autoheader, autoconf and of course automake. This is my favorite solution.
The later two options require calling configure again, IMO ideally doing an out of source built:
# in top level dir
mkdir build
cd build
../configure # arguments
make # should now also compile and link your new source file

Modifying the contents of a .cpp file

UPDATE: I am now able to compile the .cpp file with make
(I can see the compilation output). However, the changes does not seem to take affect.
After i run make, i restart the computer, but still no changes.
As you probably understand, I have very limited experience with c++.
I am currently working on a project (OpenBTS) and have found an error in one of the .cpp files after the project has been built and installed.
My question is, how can I modify the contents (f.eks change the string of a JSON data reference) of a .cpp file and build it so I can see the changes afterwards?
I have currently tried the following:
1.
make 'filename.cpp'
make: Nothing to be done for 'filename.cpp'
2.
make 'filename'
g++ 'filename.cpp' -o 'filename'
In file included from 'filename.cpp:29:0:
'filname.h':26:21: fatal error: Timeval.h: No such file or directory
#include <Timeval.h>
compilation terminated.
3. Run make from root directory:
Nothing to be done for 'all.'
4. Run make clean and make from root. This rebuilds the project but the
changes are still not in effect (I can see that the JSON String is not
changed at the webserver).
5. Run ./build.sh script. Still no changes.
Regarding the 2. method, as the project was built and compiled successfully, how come when i try that with a single file, the compiler can't find the header files? The only thing i changed was a string from "ARFCN" to "ARFCNtest".
Since there are about 50 header files that depends on each other, changing the include from <> to "" and copy every single file into the same directory seems like a waste and unnecessary action?
The changes didn't take effect because the compilation failed. See the error message you quoted in the question. Fix that and rebuild.
Incidentally, restarting your computer shouldn't be necessary. Even the make clean shouldn't be necessary if the Makefile correctly expresses the dependencies. (It seems to do so in this case since it tried to recompile the source file you modified.)

Moving to c++: no rule to make target file.c needed by file.o

I've got a source base in C using autoconf/automake, which now should be compiled using a C++ Compiler.
So I've renamed all files from .c to .cpp and changed all makefiles accordingly. However I get the following error (e.g.):
make[3]: *** No rule to make target 'tmsConfigFiles.c', needed by 'tmsConfigFiles.o'. Stop.
The Makefile basically consists of
bin_PROGRAMS = configparser
configparser_SOURCES = tmsConfigFiles.cpp tmsMoreFiles.cpp tmsEvenMoreFiles.cpp
AM_CXXFLAGS = -I .. -DSOME_DEFINE -Wall -Wextra -etc
This works for the overwhelming parts of the source code (some of which were cpp from start) but for some files the error message above appears. Did try to clean and autoreconf -is etc. to no avail.
The same revision works on Centos 6, fails sometimes on Centos 7, failes always on my Arch box.
Anyone had a similar bug in autotools or knows a workaround?
The obvious thing that I can think of is that you have not re-executed automake (or more properly autoreconf) after changing Makefile.am, and for whatever reason (there are more than a few ways for that to happen) you don't have maintaner-mode enabled.
This is, though, assuming you are actually editing Makefile.am to begin with. If you actually edited Makefile, then it's the opposite problem, automake is doing the right thing and ignoring altogether your changes by re-generating the file that should not be edited.
git clean -fx did not remove .deps directories.
Removing them manually solved the issue.

Changing name of application file (.C file)

I changed the name of an modified application to seperate it from the basic application. Lets say the .C file of the old application is "OldApplication.C" and of the new modified one is "NewApplication.C" Unfortunately, when trying to start the new modified application in terminal by typing "NewApplication" I get:
NewApplication: command not found
Two Question:
How can I make my new application executeable?
Can someone give me a brief overview about the files of a project/application and their functions?
greetings, streight
The mistake of this kind
make: * No rule to make target OldApplication.dep', needed byMake/linuxGccDPOpt/dependencies'. Stop.
often occurs in situation when the Makefile ceases to comply with the structure of the whole project.
In your case make script obviously trying to find the file that was renamed by you and therefore it fails with en error. I think that you should explore the structure of your Makefile and replace all the changed file names with its new versions.
Also you say the you are refused to launch your new executable, but what else could be expected since the project was not compiled?

*** No rule to make target 'class.cpp', needed by `build/....x86/class.o` Stop. error in Ubuntu

I got this error trying to build and compile my program. Now I can't open all my .cpp files in my program.
make[2]: * No rule to make target Checker.cpp', needed by
build/Debug/GNU-Linux-x86/Checker.o'. Stop.
Anyone can help me with this? I have checked all the online sources but I can't seem to find a solution. I desperately need this solved. Appreciate any help given.
You get this error when you don't have a file (Checker.cpp) here to make. Its probably for the following reasons :
Your current directory is not the directory in which your file
resides.
The file may have been moved to somewhere else.
Or the worse , the file doesn't exist.