How to set compiler options in Arduino Eclipse IDE? - c++

I installed the Arduino Eclipse plugin, and created a new project. I want to compile my code with the -std=c++11 option, but by default Eclipse does not use that option. Under Project Properties, for other C++ projects build options can be set in the C++ Build tab, but it is missing for my Arduino project. Is there any way to set the build options?

I recently installed this plugin, and I wanted to do the same thing, in order to generate mixed C and Assembler listing. In summary, (This is for OSX, you will have to figure out the paths if you are on a different platform.)
Look in /Users/concunningham/.arduinocdt/packages/arduino/hardware/avr/1.6.23 for a file called platform.txt.
In there you will find a line like this:
compiler.cpp.extra_flags=-Wa,-adhln -g > "$<".lst
You can see I added "-Wa,-adhln -g > "$<".lst" as extra options for the cpp compiler.
Now, this is key - restart Eclipse, clean the project in question, and rebuild. You should see your extra options take effect. Peep at the makefile to be sure.

Related

how can build options be changed in code::blocks?

I recently started using code::blocks, so I'm a newb here.
I am writing a game, in SDL with C++ and all of the code I am writing depends on the build options similar to this: g++ -Wall -o "%e" "%f" -lSDL -lSDL_image
Code::Blocks seems to work fine when I select to start a NEW SDL project, and convert my programs to project files. However, I have many source files, and I dont want to convert them all to project files, I would rather just change the build options for code blocks.
I am using version svn 10528, on Linux if that helps. I have formerly been using geany, which was very simple to change, and set build options in.
Ok, I found it, In Code::Blocks, go to Project> Build options
a window appears. it lists build options.
right click on that and add new. from there you can give it a name, add compiler options, and add linker options.
save it and youre done.
I saw some errors in the IDE when trying to use this, and found if you click continue it works fine. if you click cancel, the IDE crashes.

Eclipse CDT Kepler Importing Makefile project

I would love to import a Makefile project from Eclipse, and have all the different includes path that the compiler uses to create correctly my Eclipse project.
Unfortunately, those path, specified on the command line by a "-I" don't show up in Project Explorer and I have to add them by hand.
I am currently importing the project using the standard "Import project from Makefile" built in Eclipse.
If I'm not wrong there was an autodiscovery option in older versions of Eclipse, but it's not there anymore.
How do you do for having all your include paths set up without too much hassle?
The trick is NOT to use
File->New->Makefile Project with Existing Code
but to use
File->New->C++ Project
and then to select
Makefile project->Empty project.
After you set up such a dummy project, you simply copy your existing source to that project directory, hit F5 (i.e. Refresh) and change the build command to use your Makefile.
I was able to get this to work using Luna. I imported using File->New->C++->Makefile Project with Existing Code.
Prior to launching eclipse, you have to be sure to source any files that set required environment variables.
I did have some build options which were not the standard all and clean, so I had to add those configurations individually.
source files to setup your environment.
Launch Eclipse
Import C++ Makefile project
Setup Build options.
Click the hammer.

how to debug source code from Google code repository

I want to debug the following source code from google code repository,
http://code.google.com/p/rx/
My problem is, I am unable to find a suitable ide which can consider all the sub-folders in the source code as one complete project. I have tried netbeans C++, codeblocks, eclipse C++,etc. The problem with all of them while opening the project is that they consider all the subfolders within the main project as different projects.
Is there any ide which can be used for debugging the source code from google code repository. OR IS THERE ANY WAY OF DEBUGGING THESE PROJECTS?
Operating System: Ubuntu or Windows
You can create a dummy makefile :
all:
g++ code_dir/*/*.?pp -o fake
and then import project using Makefiles. This is possible to do for kdevelop and eclipse (not sure for other IDEs).
Take a note that the above makefile imports all files with a *.?pp template from all directories in the code_dir directory.
You can create a new project with your favorite IDE and then import the sources manually.
You might also consider using a decent editor. Personally, I prefer vim and don't see any appealing reason to use an editor 10 times the size of the actual project.

"Program is not a recognized executable" error in Eclipse

I'm trying to debug a C++ programme in Eclipse Indigo. The project is using autotools/configure (and the respective plugin) as build system.
After successful build I right-clicked on the binary in the project browser and chose "Debug As". Then I used the file browser to select the binary. Clicking on "Debug" then opens a dialog which just says "program is not a recognized executable".
Any ideas?
I found the answer: the binary parsers configured in eclipse were the wrong ones. Adding the correct binary parser under Project --> Properties --> C/C++ Build --> Settings solves he problem.
If you're using libtool in your project, what looks like the binary may actually be a wrapper script used to set LD_LIBRARY_PATH and stuff like that before executing the real binary (which is stored in the .libs directory). This may be what causes Eclipse to fail, but I'm not sure how you should go about fixing that.
There seem to be a bit of documentation about Eclipse CDT and libtool on the internet which may have the infos you need though: http://www.freerdp.com/wiki/doku.php?id=eclipse#debug_configuration
From OSX snow leopard on, gcc seems to build 64 bit executables by default. And those won’t be recognized from Eclipse in return. To solve the error, you’ve got to explicitly set your architecture to i386.
Enter your project properties and add the command line option “-arch i386″ for each C++ Linker, C++ Compiler and C Compiler. After a clean build, you should be clear to debug again. In Linker options make sure to NOT set it up as -Xlinker option.
Original Source

Netbeans C++ additional commands (using tolua++)

I am building a C++ project that uses tolua++ for binding.
When building 'by hand'. at the command line, I am entering the following command:
tolua++5.1 -o ../src/LuaBinding.cpp -H LuaBinding.h Binding.pkg
I don't know where to enter this command line in the Netbeans IDE.
Can anyone help?
Depending on how you created the project, you might have a Makefile. (For example, if when creating the project, you selected "C/C++ Application" then NetBeans created a Makefile for you.)
In the Project pane, you would have a node called Important Files, and in there should be Makefile. I am assuming you can put what commands you need into the Makefile. The makefile NetBeans gives you in Important Files actually allows you to augment its own standard makefile targets by adding commands to the pre and post targets. To get more control over the make process you could replace NetBeans' make files with a completely custom set. That would mean that you would need to hook up your own targets to menu commands--not rocket science but beyond the scope of this answer.
If it is more general than that... if all files are built with tolua++, then you can establish it Build Tools Tool Collection. Click on Tools, then Options, then click on the C/C++ icon in the Options dialog's toolbar, and then on the Build Tools tab. In that case, the standard NetBeans makefile (or whatever custom makefile you've provided) will simply use that without having to muck through the makefile itself.