I've a C++ project in eclipse which is version managed with git. I've a git submodule, which is another project I've written in C++. The submodule has its main function and my project has its own.
Eclipse chooses other main (from the submodule) to compile when I press build. Is there a way to choose which main to build in eclipse?
Update: I'm still working on the issue. Excluding resources from the project didn't help either. Will answer the question when I solve it.
Update 2: Solved at last. See my answer.
I have solved the problem, at last. The solution is not a simple and straightforward one, so I'm writing step by step:
First set your toolchain correctly from Properties -> C/C++ Build -> Tool Chain Editor -> Current toolchain
. It's MacOSX GCC
or Linux GCC
for me.
Set your correct project source path. I've symlinked the files from projects I imported as submodules to my project, so setting the correct source directory didn't exclude any required files from my project. Setting is at Properties -> C/C++ General -> Paths & Symbols -> Source Location
. Make sure you exclude the other submodules and symlink the required files to your project.
Change the name of the artifact (binary, library, etc.) to something different than the ${projName}
, because when you have submodules, you will have a directory named as ${projName}
inside your build folder. Setting is at Properties -> C/C++ Build -> Settings -> Build Artifact -> Artifact name
.
After making these changes, your project should build automatically. Looks like eclipse makes all necessary checks during build, but doesn't warn you about the problems. I had to see all these problems with running make --always-build
inside the Debug
folder.