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.
Related
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.
Is there any IDE that exports Kconfig files to automatically add include and source folders, as well as setting the actual symbols that are defined there?
I mean, it's next to impossible to have a complete Eclipse environment for Linux Kernel development. Right now I basically have a "Makefile Project" with chosen include and source folders and built in build, but my code is dependent on symbols defined in kernel build.
EDIT
I just realized that kernel build generates a include/generated/autoconf.h, which is a great help in this and probably enough for most of the developers
There's a KDevelop plugin called kdev-kernel: https://github.com/Gnurou/kdev-kernel . It was an improvement over loading the kernel as a "generic makefile project" but isn't a complete solution.
It seemed to ignore some .config options, and it only works with specific versions of KDevelop. I'm not sure which ones, as I use Gentoo and usually compile a -9999 version of KDevelop (in Gentoo, -9999 indicates the head of some revision control branch... so the version depends on when I compiled).
In spite of the drawbacks, it might be worth trying or building upon; I find KDevelop's "intellisense" very useful.
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!
I have a large project that is rather heterogenous - different languages and compilers are involved, altogether producing a build with the help of GNU make.
The project folder structure includes:
project
src
haxe --Haxe source code
graphics --Embeddable graphic resources
locale --Locale-specific resources
chinese --Chinese language resources
english --Generic English resources
build
china --Chinese market
debug --Debugging/Testing for developer(s)
release --Release
europe --European market
debug -- ...
release -- ...
All builds are produced by setting up and running 'make'. What I can't decide on is whether these makefiles should be put in 'src' directory as well? I generally consider original material I write by hand to be source code (since by my line of thought it originated from me and not produced by any program from some other input.) and I DO write my makefiles by hand. Another reason I consider this is because ONLY 'src' directory is a Git repository - I don't really need to version track anything else. Do I put all Makefiles into 'src'?
What's currently in your build directory structure? Is that the compiled output?
Intuitively (and I may be coming from a very different development world than you, so "intuitively" is a relative term) when I see a build folder adjoining a src folder, I expect the program's source code to be in the latter and the scripts/tools/etc. needed to build it to be in the former. The scripts (makefiles in this case, though potentially also to include other things) are themselves source code, as you state, but aren't the program's source. The distinction is that one is "what is being built" and the other is "how to build it."
If I understand you correctly, src is what's bound to your source control and build isn't? Under that circumstance, I would probably create a build (or builder or building or something of that nature) under src to house the scripts. It may be slightly unintuitive that it has to climb another folder before producing its output, but it should sit nicely alongside the resource folders you have there already.
Standard practice is to create a Makefile outside your src/ directory, which builds your project and within that src/ directory, another Makefile builds individual modules. That said, I think in your case it is sufficient to keep your Makefile solely in src/ though. I'm not sure if this applies, but you might want to look at the GNU autoconf package, it's used for exactly this type of thing.
Can I have a Library defined that makes use of JNI in NetBeans?
Seems the library definition only allows Jars or Folders.
How can I assure that the DLL follows the jar file when the app is built?
Assuming you are referring to building a NetBeans Platform App (or module), then you can place the DLL in the "release/modules/lib/" folder. This is per the platform FAQ:
http://wiki.netbeans.org/DevFaqNativeLibraries
Additional information here:
http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#jni
If you are asking more generally, then I think most people package the DLL inside the jar, then extract it to a temp location upon application startup. e.g.
How to make a JAR file that includes DLL files?
If that's not what you're looking for, then you'll need to provide more information as to what you're trying to do.
netbeans won't do it on its own, but since it uses ant behind the scenes there's a workaround.
you should create a subdirectory named jni in your project directory (c:\path\to\mynetbeansproject\jni), put all the .dll, .so and .jnilib files in there (the native stuff), and add the following lines to the build.xml file you find in your project directory, just before the </project> tag:
<target name="-post-compile">
<copy todir="${dist.dir}/lib">
<fileset dir="jni" />
</copy>
</target>
then add the jar file to your project just like you always do. :)
the snippet you inserted in build.xml will make sure that the native libraries follow your jar files in the dist/lib folder when you invoke "Clean and Build" from within netbeans (or ant from the command line); the jvm will look for the .dll (.so, .jnilib) files in the same directory as the .jar that's loading them, so it will work.
note that this won't make your project run from within netbeans, becauseā¦ I'm not really sure what goes on, but it looks like the library path (LD_LIBRARY_PATH) doesn't include your projects' libraries, and there's no way I know of changing it from within netbeans. just put your native libraries in /Library/Java/Extensions on mac os x, or just stash them in c:\windows\system32 under windows. if you're running a 64 bit windows with a 64 bit jvm, I have no clue; if you're running linux, you probably know where to stash them, but /usr/lib/java might be a good bet.
I tested the following solution while using NetBeans 7.0.1 and it worked, but I don't know if it works in early versions, too.
The solution is easy and works per NetBeans module. So, if you have a suite, don't place its JNI files into suite project, instead, place the JNI files that you want into the module itself. Do:
Find a NetBeans module project that you want (or need, or think) to place your JNI libraries (them with extension .DLL, .so and .jnilib, by eg);
At Projects, right click at the module node, click at Properties menu;
In the Project Properties dialog, click at Libraries and Wrapped JARs. You must add any external library there. I added the RxTX jar library. After add your external libraries, the Netbeans Ant script will copy all files/folders from the directory your_project_dir/release to the right location when you build the solution.
So, place your native libraries at your_project_dir/release/lib. If you want, you can create subdirectories for each target platform that you need, as: your_project_dir/release/lib/amd64, your_project_dir/release/lib/sparc32
To know, more, read:
http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#jni
Regards,
marciowb.info