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 GCCor 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.
I setup eclipse IDE to use openCV. I followed the tutorial provided on openCV website. However, there is this extremely annoying issue am facing every time I create a new project. It seems I need to redo the entire process of pasting the library files in GCC C++ linker for every project that I create. Is there anyway of making them persistent for all new projects ? Or to at least be able to export the settings so that I can import them which will save time.
Thanks
I may have misunderstood the question, but if you just don't want to set up the project each time, you can save a build configuration in Eclipse.
To use another projects build configuration:
Project -> Properties -> C/C++ Build
Click Manage Configurations and create a new config (call it opencv or whatever).
Then set up your Includes, GCC linker etc as you have done before. Then hit Apply.
Now if you ever want to set up a new project with these configs, select your new project:
Project -> Properties -> C/C++ Build -> Manage Configurations
Click New and select 'Import from projects' and select your 'opencv' configuration. This will import the build set-up into the your new project.
Then just select it from the Configuration drop-down.
To export the build configuration as an XML file:
Right click project -> Export...
Select C/C++ -> C/C++ Project Settings
Select the Configuration you want to export and save it somewhere.
To import it into a project:
Right click project -> Import... -> C/C++ Project Settings
and browse for your config file
Hope this helps!
I am facing some problems regarding eclipse for c/c++. I am trying to create a new project, I provide the code, and after running the code I get this error:
The program file specified in the launch configuration does not exist
C:\Users\elisabeth\workspace\mm\Debug\mm.exe not found
Please notice that I am working with spice toolkit; I set the path for the "include" files and the libraries, but still I can not have a result.
What causes this error and how can I resolve it?
Right click on your project --> Properties
Run/Debug settings
Delete whatever is set as "launch configuration for '........'
Project --> Clean
Project --> Build Project
You can create a run configuration. Go to Run > Run Configurations. Click New button, fill C/C++ Application field, i.e., insert path to your executable. The new configuration will appear in the list which appears when you click to the arrow next to run button.
Of course this assumes your can build without problems, otherwise you won't see an executable to point to.
You can clean the project, build it again and run it as a local C/C++ application. Simplified steps as follows,
Right click on the project
Clean Project
Again Right click on the project
Build Project
Again Right click on the project
Run As ->
Local C/C++ Application
As the error reads:
C:\Users\elisabeth\workspace\mm\Debug\mm.exe not found
First of all you need to check whether there is an executable "mm.exe" in your Debug folder. (Of course, it is not there and that is why the error)
Go to Project > Clean
and you should see some files being deleted from your Debug folder
Go to Project > Build Project
and you should see some new files being generated e.g. mm.d, mm.o, mm. This "mm" is probably the executable you're looking for
Now that you know what your executable is, you should tell eclipse what file to execute instead of mm.exe. Go to Project properties and in run debug settings create a new configuration (or edit an existing configuration, if there is one already). In this configuration, in main tab, in C/C++ Application specify a full path to "mm". Which, in your case is - "C:\Users\elisabeth\workspace\mm\Debug\mm"
A better way to do this in eclipse is:
${project_loc}/"your folder"/"your executable file"
e.g.${project_loc}/Debug/mm
what worked for me is file->refresh
then do the Debug configuration again by choosing the right c/c++ binary again.
Avoid troubles with configuration by going into Project properties > C/C++ build > Refresh Policy and specify your project folder. The configuration option "Search project" will show a correct folder then and you will see whatever you build there - Debug, Release or both. You don't want to specify the folder using Browse option every time you import project or switch configurations.
As this is the first SO discussion that appears for this topic on Google and none of the answers solved the problem my students were having, I would like to mention the solution we eventually found from this answer:
Open project properties (Right click on your project, choose Properties on the menu)
C/C++ Build -> Settings
Click on Binary Parsers tab and check PE Windows Parser
Keep clicking Move Up until it is at the top
This had been set to Elf, even though we were using a freshly downloaded Windows version of Eclipse.
sometime missed closing curly brace can be part of a problem. Make sure prototype your function at the beginning of the file. Then right click your project in the left side bar. click clean project. then click build project and finally run project
I encountered similar issues and their related problems a few days ago. Finally, I found out that, just because I had moved my project folder (workspace folder of Eclipse) to another place so Eclipse could not find what its need as usual.
Solution: I just set the workspace to my new place (Hey Eclipse, my workspace now is here) :
Menu "File" -> "Switch workspace" -> "Other..." -> click "Browse..." button and point to new place then click "Select Folder" button and click "Launch" button.
Nice day.
I'm not a regular C++er, so this question might be fairly trivial: Can anybody please tell me what I need to do that during the build process some folders will get copied to the output directory?
My project is currently structured somewhat like this:
Projects
-> ProjectName
-> .cpp and .h files
-> Folder1
-> Folder2
-> Debug
-> Release
Folder1 and 2 contain some files that are required during runtime, so they need to be shipped with my application - how do I get those into Debug/Release while building the project? Or is there any other recommended method to deal with such situations?
Under the projects properties, use build events, and on the command line enter the equivalent command codes to copy the files.
I've found similar questions across the internet, none of which helped me. The Code::Blocks workspace and project files included DO generate .a files, and I've moved them to Codeblocks/MinGW/lib, and I've moved the Box2D folder to Codeblocks/MinGW/include and yet the HelloWorld.cpp example still gives me these errors.
Looks like the project files you used to build the .a were missing some files. The file mentioned in the error message is one that was removed from Box2D after v2.1.2, so I'm guessing you are using 2.1.2 source code (or thereabouts) with project files from some other source?
In any case, setting these up yourself is really simple. In the 'Management' panel, right click the 'Engine' project, select Remove files and click OK to remove everything.
Now do the same and select Add files recursively, choose the folder that contains Box2d.h file:
Click OK a few times, and you're done.
In your case, since you had it building already I would expect this to be ok now but for anyone arriving here wanting to setup a project file from scratch, you'll also need to specify the search path for the Box2D headers.
To do this, in the same right-click menu choose: Properties -> Project settings tab -> Project's build options button -> Search directories tab -> Add button. Now choose the parent folder of the one you just chose above.