On Thu, 11 Aug 2022 14:18:29 +0800 "ljh" <l...@qq.com> wrote:
> main : c.o b.o a.o d.o main.o > A: note: imports must be built before being imported > A: fatal error: returning to the gate for a mechanical issue > compilation terminated. > make: *** [<builtin>: main.o] Error 1 With the compiler anc C++ language you are using it seems as if it is required that a.o, b.o, c.o and/or d.o is built before main.o. If so, you will need to specify a dependency like this: main.o: a.o b.o c.o d.o > 3. ok: with target.o and recipe > > $ rm -fr *.o gcm.cache main > $ cat Makefile > CXXFLAGS = -Wall -Wextra -std=c++2a -fmodules-ts -g # -O3 -fPIC > main : c.o b.o a.o d.o main.o > $(CXX) $^ -o $@ > $ make > g++ -Wall -Wextra -std=c++2a -fmodules-ts -g -c -o c.o c.cpp > g++ -Wall -Wextra -std=c++2a -fmodules-ts -g -c -o b.o b.cpp > g++ -Wall -Wextra -std=c++2a -fmodules-ts -g -c -o a.o a.cpp > g++ -Wall -Wextra -std=c++2a -fmodules-ts -g -c -o d.o d.cpp > g++ -Wall -Wextra -std=c++2a -fmodules-ts -g -c -o main.o > main.cpp g++ c.o b.o a.o d.o main.o -o main That Makefile might seem fine and seem to work, but what would happen if you would run "make -j 5"? Then, again, those other object files would not have been built before main.o. So to work correctly with parallell builds, that Makefile would probably also need a rule like: main.o: a.o b.o c.o d.o regards Henrik