Imagine the following folder structure:
How can I compile code.c in code.o and directly put it in bin? I know that I can compile it in code.o under src and make "mv code.o ../ bin", but this will lead to an error if there are compilation errors, right? Even if it works this way, is there a better way to do this?
Thank.
The process should or should not "give an error" depending on what you mean. If there are compiler errors, you will find out.
However, there are several ways to do this with make. In this case, it is best:
$(MAIN_DIR)/bin/%.o: %.c $(COMPILE)...
, . , makefile.
$(subst $(notdir $(CURDIR)),,$(CURDIR))
:
~/myProject/ src/ Makefile #all the .c and .cpp bin/ #where you want to put the binaries.
$(CURDIR) ~/myProject/src
$(subst $(notdir $(CURDIR)), $(CURDIR)) ~/myProject
, , , &&:
&&
code.o: code.c code.h g++ -c code.c && mv code.o ../
mv code.o ../ , g++ 0, . , makefile, , , .
mv code.o ../
g++
makefile
cc -c code.c && mv code.o ../bin
This will not execute the mv part if cc fails.
Source: https://habr.com/ru/post/1740609/More articles:Копировать строку - Python - pythonDelphi - WndProc () in a thread never called - multithreadingPython NameError при попытке использовать пользовательский класс - pythonBest way to communicate between .Net applications? - vb.netOnpaint events (invalid) change the order of execution after a period of normal operation (runtime) - c #How to search from a list with keywords without a prefix - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1740611/rails-how-can-i-combine-multiple-model-attributes-to-create-a-unique-permalink-using-permalinkfu&usg=ALkJrhgU4cg2OiIu90YKfq0ie9iV7k1oKgHow can I put an image in a row using NSString on an iPhone? - iphoneSquare number in NASM assembly without multiplication - assemblyHow to create a runtime protocol in Objective-C? - objective-cAll Articles