如何在Eclipse中一次构建多个源文件

问题描述 投票:-1回答:1

我有一个Eclipse C ++项目,最初有first.cpp。然后添加second.cpp并且应该链接到原始文件。使用Eclipse构建工具,我得到了这个输出:

make all 
Building file: ../src/first.cpp
Invoking: GCC C++ Compiler
g++ -I/home/workspace/first/src -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/first.d" -MT"src/first.o" -o "src/first.o" "../src/first.cpp"
Finished building: ../src/first.cpp

Building file: ../src/second.cpp
Invoking: GCC C++ Compiler
g++ -I/home/workspace/first/src -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/second.d" -MT"src/second.o" -o "src/second.o" "../src/second.cpp"
Finished building: ../src/second.cpp

Building target: first
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o "first"  ./src/first.o ./src/second.o
Finished building target: first

如何让Eclipse以这种方式编译?

g++ first.cpp second.cpp -o first

非常感谢。

============================================================================

我问如何从多个源文件制作单个二进制文件,而不是building multiple binaries with multiple source files

c++ eclipse compilation g++
1个回答
1
投票

尝试使用CMake根据我对您的问题的理解,您需要将源文件添加到CMakeList.txt然后运行它。你可以利用this tutorial这样做。

© www.soinside.com 2019 - 2024. All rights reserved.