Eclipse: Juno on Ubuntu 13.04
I'm trying to build a Clang project under Eclipse. I got and installed the llvm4eclipsecdt add-in and it works, I guess (it does compile to object files).
My problem is that I have a mixture of C++ and C source files (.cpp and .c extensions), and when I create a new C++ project, all the cpp files are included, but not the C files. And vice versa if I create a C project.
I'm thinking what I actually want is a C++ project and tell the C++ compiler to build the C files.
However, I have a lot of C files in my project, and I don't want to manipulate each one by one to tweak their build options or whatever.
Is there anything I can do project-wide to say "Yeah, I know this is a C++ project. Go ahead and compile the .c files too?"
Thanks!
Related
When I create a Fortran project by Eclipse,
it includes bin and src directories.
The automatically created Makefile has a rule that compiles test.f90 in src and its runnable is written in bin.
I am a pretty new to Fortran.
What if test.f90 is supposed to be just an object which is required to compile an executable file, where should the object file, say test.o, be put? and when test.f90 has a module inside, where should the module test.mod be output? mod at the same level as src and bin. or share, lib?
In that case, when I should separate all intermediate file in several directories, are there any template Makefile?
It depends on what kind of Fortran project you created. If you created a Makefile project, you have full control/responsibility for where files are located. It appears to create a src and bin directory but beyond that, it looks like you can put other files like *.mod and *.o wherever you want. I'm not sure what the convention is for Fortran Makefile projects.
I prefer to avoid using Fortran Makefile projects because I have zero desire to manually sort out dependencies and targets with Makefiles, but that's a personal preference; if you're familiar with make and need the fine control it gives you, this is a reasonable choice. Just starting out with a Fortran Makefile project seems really painful unless you already know make.
A simpler, though less obvious to choose "File | New | Fortran Project | Others" when creating a Fortran project, then select the compiler and what you want to build. An example is "Executable (Gnu Fortran on Linux/*nix)" for building an executable with gfortran on a unix/linux-like system. Build targets include executables, static libraries, and shared libraries, each using gfortran, ifort, and a few other compilers, on Windows, OSX, or linux/Unix.
The src and bin directories are not automatically created but Makefiles are managed by Eclipse. Eclipse will automatically create a directory like Debug or Debug_Intel64 and place executables, *.o, and *.mod files within it. If you make your own src directory, object files will be placed under Debug/src but the executables and module files will be under Debug. This directory name changes if you create a Release build configuration (Debug is the default).
By default, Eclipse puts all new source files in the project root but you can create Fortran source folders and organize your project however you want. The downside of automatic build management is that Eclipse is really only set up to build one thing, so if your project contains multiple executables (e.g. separate unit test, utilities, etc.) you need to manually build with make, CMake, etc.
Eclipse takes some getting used to, but integration with Mercurial is pretty good, and the Photran plugin (part of the Parallel Tools Project) helps with source templates, code analysis & Fortran refactoring tools, and a reasonably decent UI for configuring the compiler (at least for ifort on Linux). Plus it's cross-platform and works with a lot of other languages so it's far from the worst choice, especially if you're using Photran.
If you're not sold on Eclipse, I'd look at some less heavyweight options. Eclipse can be a pain some times and you might find a better IDE for what you're doing. OTOH, Eclipse works fine and the Photran plugin has some really nice features.
For fortran beginners the best IDE is codeblocks
download the binaries with Mingw fortran compiler.
As your requirement it puts all your .mod and .o files to obj folder and executables in bin folder and source files are just used from the directory where they are.
I am new in the cmake world and I am not even sure if what I try to achieve is possible or not.
Currently, I have an eclipse project file which contains many targets (they have some files in common, some are different (I used the exclusions in Eclipse to do it)).
One of my colleague uses the CLion for that so he created a CmakeLists.txt files for that. Is it possible to use these CmakeLists.txt files to create a project in eclipse? Is it possible to have this way a multiple targets in one project file?
Is it possible to use these CmakeLists.txt files to create a project in eclipse?
Yes, use the following from your source root to generate Eclipse project files which support in-source builds.
$ cmake -G"Eclipse CDT4 - Unix Makefiles" .
If you want to do out-of-source builds, there are a few wrinkles to be aware of. Have a look at this cmake wiki page about the Eclipse CDT generator for more details.
Note that Eclipse also supports importing projects from existing makefiles, which means you can just use the "Unix Makefile" generator to generate makefiles, and import from those.
See this cmake wiki page for details on that
Is it possible to have this way a multiple targets in one project file?
Yes it is. All targets specified in your CMakeLists.txt file(s) will be included in the generated project file.
Thank you for a quick answer. I looked into what you sent me but my indexing still does not work. In my project I have following structure:
Folder main with main.c
Folder platform with three different folders: folder a with a.c file, folder b with b.c file and folder c.c file, and one platform.h file common for all those files with declaration of function "platform()". The main function calls the function "platform()" from platform.h which definition is different for each target (a, b, and c respectively defined in a.c, b.c and c.c file). When I create the eclipse project I do get the folder called "[Targets]" but the indexing does not work which means it does not show me the function from the proper target.
Is it possible to be able to switch from one target to another with the "hammer" sign?
Many thanks.
I am using an Eclipse based IDE (QNX Momentics.) I have several projects in my workspace. I have Project A, B and C. Project C has dependencies on Project A and B. If I go into the IDE and properties of "C" and Project References, and I check A and B, then I can go and do a "build" of C, and it will build A and B if they aren't already built. This works fine in the IDE. If I do a clean, and go out to a command line, and do a "make" under the C project, then it does not compile A and B, and thus gives me some errors. (can't find certain library files). I see a flag that has "A" and "B" projects in the .project file, but I don't see any rules anywhere to instruct it to build. Any help on this is appreciated. By the way, this is a C++ project if that matters.
I can build referenced projects whereas they are cleaned. I suppose your C project is a makefile project. So, it may change the behavior of the IDE.
Momentics creates a runtime makefile for "QNX C/C++ Project" type. Therefore, you cannot see all rules.
I am trying to run the code from below link which contains C++ codes.
https://github.com/cjcliffe/CubicVR
This link contains the BeatDetektor app for iPhone. But this is developed using C++. How can i run this project?? There are no xcode project file. Also i am trying to run main.cpp file but there are lots of package files error...
below is link for BeatDetektor app
http://www.cubicvr.org/index.php?option=com_content&view=article&id=67&Itemid=82
Can anyone tell me how to run C++ file in Xcode or on terminal???
Xcode is an IDE, not a compiler. It builds targets of various types by using a compiler like GCC internally. If there is no Xcode project file, you can create one yourself and add the source files to it. As far as I know Xcode will not compile source files on their own.
Using CMake software i am able to convert my cpp project to Xcode project... As github code contains .make extension file...
the code i develop for avr microcontrollers i write so that it runs on the PC and only differs in one or more files (the port). till now i do that using makefiles but now id like to move to eclipse CDT with the AVR plugin.
is there a way to
use 2 different toolchains (x86 and avr compiler) in one project (and also tell these toolchains which port to include)
or to create 2 project (one for x86 one for avr) that share the common files?
note that main() is in a shared file.
thanks for your help.
You may be able to set up multiple configurations to do this, with different toolchains. If this looks reasonable, you could have your source files change their behaviour based on what compile-time symbols are present.
Within Eclipse, only the x86 compiler will be used (so you can run the tests, etc). You will have to invoke the Makefile to build for AVR manually, so one project should be enough.
Eclipse will not use the output of the compiler but the C sources to build its project model. Therefore, you will see all files (even those for AVR) but they will never run in Eclipse. That means you can edit them including code completion.