I would like to import an C++ GUI Project with its own Makefile in Eclipse.
In the command prompt, everything works fine. But when I import the project, it gives an error
make all
make: *** No rule to make target `all'. Stop.
Would be glad, if you give me an idea where I am going wrong.
Thanks
Kiran
How did you import the project? I have used Eclipse with existing makefile projects a couple of times by creating a new empty makefile project and overriding the location of the project to refer to where the Makefile is present. It warns that the directory already exists, but it works fine.
Make sure that your Makefile has an "all" target.
A typical all target rule could look like
all: ../bin/myApplicationName
#true
You'll probably also want to include a rule for clean if you don't already have one.
clean:
#-rm -f ../bin/myApplicationName *.o *.d
Related
I am trying to make a phony target on make so that my "all" target doesn't run every time even if the prerequisite files haven't changed, but make still runs every target every time I run it.
Here is an example Makefile:
CXX = g++
CXXFLAGS = -Wall
.PHONY: all
all: testing testing2
testing: testing.cpp
testing2: testing2.cpp
clean:
del *.exe *.o
The due to declaring all as a phony target using .PHONY, the intended result is that by running make, the "testing" and "testing2" targets should only be ran if their respective results (testing.exe and testing2.exe) are older than their prerequisites (testing.cpp and testing2.cpp). However, every time make is run, both targets are ran as well. I am using make on windows installed via chocolatey, make --version is GNU Make 4.3 Built for Windows32.
Do phony targets not work on make windows?
Your rules say you'll build the files testing and testing2. But your recipes don't build those files, they build the files testing.exe and testing2.exe.
So when make runs, it looks for the file testing to see if it's up to date and it doesn't exist, so make runs the recipe, which builds testing.exe. Then the next time make runs, it looks for the file testing to see if it's up to date and it doesn't exist, so make runs the recipe, which builds testing.exe. Etc. etc.
This has nothing to do with PHONY which only applies to all so why would it be related to rebuilding testing?
You need to name your targets in make with the same name of the file that your recipe creates.
I am working on a c++ project and I am using cmake as the build system, so my workflow here is make changes to code. then,
rm -r build
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
Now I added glew as a dependency to the project, so whenever I try to run make I get an error saying SDL.h not found(this was working before).After sometime I decided to check CMakeCache.txt.opened it using vim then :wq that's all I did now if I run make, my project is building successfully, I am not sure why this is happening, Can anyone tell me why?
ps: added gif of this event, check it out to get a clear picture
(the code i am working on is linked as well, this exact issue is in this commit "dd4452b45c733e0612bc5f3c632e9d1a08be8072")
link to gif
link to code
variables in cmake are limited to the scope of the directory they are in plus their subdirectories.
This, calling find_module() in the gamelib subdirectory does not find that module for use in the main directory.
The preferred way to propagate include directory dependencies is to add them to the target (in the gamelib directory), like this:
target_include_directories(gamelib BEFORE PRIVATE
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIR}>
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
target_include_directories(gamelib SYSTEM BEFORE PUBLIC
$<BUILD_INTERFACE:${SDL2_INCLUDE_DIR}>
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
then you don't need to even mention them in any executable that uses gamelib.
I'm compiling C++ code for Webots (a robotic simulator), by means of makefiles, and I'm using the generic makefile Makefile.include Webots supplies to ease the process.
I build by own makefile, set a bunch of required variables and then call that makefile that sets all the necessary rules for compilation. That's how it was supposed to work anyway.
I'm getting the following error:
make[1]: *** No rule to make target 'USER_PREBUILD'. Stop.
/usr/share/webots/resources/Makefile.include:503: recipe for target 'pre-build' failed
make: *** [pre-build] Error 2
And looking at the relevant line (from Makefile.include):
$(SUPPORTED_TARGETS): post-build
USER_PREBUILD:
USER_POSTBUILD:
pre-build:
#$(MAKE) --silent USER_PREBUILD
post-build: main-build
#$(MAKE) --silent USER_POSTBUILD
$(TARGETS): pre-build
main-build: $(TARGETS)
I'm not sure if there is not a syntax error when calling make in the pre-build and post-build, or if USER_PREBUILD and USER_POSTBUILD are supposed to be concrete files, but even if replace them with $(USER_PREBUILD) I get *** No targets specified and no makefile found.
So I assume I would need to set those variables before calling the external makefile, but what exactly is the syntax if I don't have anything to be done before building?
Strangely, even despite these errors, the program compiles (I get the *.o, *.d and the binary on the build folder), but it never copies the binary to the destination folder.
That's a bit of an odd way to have set things up in that file.
The USER_PREBUILD: and USER_POSTBUILD: lines have no effect and are not doing anything for anyone (at least that I'm aware of).
You have two choices for how to solve this problem.
You can provide empty rules for the USER_PREBUILD and USER_POSTBUILD targets in your makefile:
USER_PREBUILD USER_POSTBUILD: ;
or you can avoid even the attempt at running those targets (at the cost of an over-riding warning message from make) by using these lines:
pre-build: ;
post-build: main-build ;
in your makefile after the inclusion of Makefile.include.
I'm getting the error "No targets specified and no makefile found. Stop."
however I'm running the "make" command for my Makefile.cpp in the same directory.
So I just wanted to do a simple makefile to run my three separate files:
all:
g++ gameoflife.cpp functions.cpp header.hpp -o gameoflife
The second line is tabbed once.
Let me know if I need to rename the files or how exactly to run the make file correctly. Thanks. Also this is all being run in a UNIX server with make installed, etc.
The make command uses the makefile with the the name that you specify with the -f option. If you don't use the -f options it uses the file Makefile without the .cpp appendix.
Your editor might have save your Makefile as Makefile.cpp. Check that you use the correct name.
Edit:
To be more specific: The GNU make searches for one of these files in that order:
GNUmakefile
makefile
Makefile
I'm not used to making makefiles. My old project had all the makefiles in place and I'm making this from scratch for a small test with a lot of canned lib dependencies that I'm not used to either. It's been a few years since I looked at makefiles.
I have a directory called libopcTest with the following in it:
LibOPCTest.cc
LibOPCTest.h
makefile
makefile has this in it:
INC=-I/usr/include/libxml2/libxml
LIB=-L/usr/include/libxml2/libxml
all: LibOPCTest.exe
LibOPCTest.exe: LibOPCTest.o
>tab> gcc -o LibOPCTest.exe LibOPCTest.o
LibOPCTest.o: LibOPCTest.cpp
>tab> gcc -c $(INC) $(LIB) LibOPCTest.cpp
clean:
>tab> rm LibOPCTest.o LibOPCTest.exe
I looked in /usr/include/libxml2/libxml and it does have xmlstring.h in it. I don't see the libxml reference in opc.h, but apparently that's where it comes in, presumably in an include file, like config.h.
Plus, we have LibOPCTest.cpp which #includes <opc/opc.h> and it's own .h file.
main is in LibOPCTest.cpp.
When I type make at the Linux command prompt, I get the following error:
In file included from /usr/include/opc/opc.h:36:0, from LibOPCTest.cpp:1:
/usr/include/opc/config.h:37:30: fatal error: libxml/xmlstring.h: no such file or directory.
Shouldn't I have the libxml with the LIB and INC definition in the makefile pointing to libxml? I don't think I'm supposed to add anything to opc.h, including build it, since it's a canned library.
I was looking at this makefile example, and I think I have everything I need (probably not since it's not building).
I know it's a basic question, but hopefully someone has a good suggestion. Thanks for being nice in advance!!
We decided to put the Linux version of libOPC on hold because there isn't a good 64 bit version and it needs a lot of work.