Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 571
Panke Avatar asked Dec 14 '25 02:12

Panke


2 Answers

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.

like image 69
Diego Elio Pettenò Avatar answered Dec 15 '25 16:12

Diego Elio Pettenò


git clean -fx did not remove .deps directories.

Removing them manually solved the issue.

like image 20
Panke Avatar answered Dec 15 '25 14:12

Panke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!