简体   繁体   中英

How to compile multiple unrelated .cpp files using one g++ command

I am checking some assignments and they have multiple .cpp files each with its own main function. And have different file names.

I want one or a series of g++ commands that I can execute, which will give me a separate executable of each file.

How do I do that?

由于您使用的是g ++进行编译,因此我假设您可以访问shell:

for f in *.cpp; do g++ "$f" -o "`basename "$f"`"; done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM