How to Debug Following Fortran Program - debugging

I am trying to compile the following software so that I can step through and debug it. I am only a novice programmer and I am trying to understand how this whole makefile business works with Fortran. I know that there is a ton of literature on makefiles but I just need to insert a simple debug flag and I think if someone provided me with the answer to this question that would be the best way for me to learn.
So the program I am trying to compile, TINKER, is actually made up of several packages, located at http://dasher.wustl.edu/tinkerwiki/index.php/Main_Page. I would like to compile and debug JUST ONE specific executable, "analyze". I contacted the developer and received the following reply but I am still stuck...
Since TINKER has lots of small source code files, what we do is
compile each of the small files to an object file using the "-c" flag.
Then we put all of these object code files (ie, the ".o" files) into
an object library. Finally, we link each of the TINKER top level
programs, such as "analyze", against the object library. There is a
Makefile supplied with TINKER that does this. We also supply
individual scripts called "compile.make", "library.make" and
"link.make" for various CPU/compiler combinations that can be run in
order to perform the steps I describe above. To build a "debuggable"
executable, you just need to include the appropriate debug flags
(usually "-g") as part of the compile and link stages.
I am currently running OSX 10.6.8. If someone could show me which folders I cd into, what commands I enter that would be so great!
Thanks!
My follow up question (once I can figure out how to answer the above via command line will concern how to import the same procedure but using the Photran IDE - http://wiki.eclipse.org/PTP/photran/documentation/photran5#Starting_a_Project_with_a_Hand-Written_Makefile)

The directions are at http://dasher.wustl.edu/tinkerwiki/index.php/Main_Page#Installing_TINKER_on_your_Computer
Maybe out of date? g77 is obsolete -- it would be better to use gfortran.
The key steps: "The first step in building TINKER using the script files is to run the appropriate compile.make script for your operating system and compiler version. Next you must use a library.make script to create an archive of object code modules. Finally, run a link.make script to produce the complete set of TINKER executables. The executables can be renamed and moved to wherever you like by editing and running the ‘‘rename’’ script."
So cd to the directory for the Mac -- based on "we also provide machine-specific directories with three separate shell scripts to compile the source, build an object library, and link binary executables." Then run the command scripts. Probably ./compile.make. Look around for the directories ... you can probably figure it out from the names. Or search for the file "compile.make".
Or find someone local to you who knows more about programming.

Related

How to code a script to create a makefile

i'm new year and I need some answer. I searched on the web to some answer but i didn't found anything usefull. What am i searching is for a shell programms that when you execute it, create a Makefile with the binary name in arguments like :
./automakefile.sh hello .
Will build you a Makefile with a binary name called hello.
I hope you guys will help me, i'm counting on you <3
There is, unfortunately, no such magic command. If there was, we wouldn't need Makefiles to start with because the magic would most likely have been incorporated in the compiler.
There are several reasons why there isn't a command like that.
Given a random binary file, you can't generally say what programming language it was written in.
You also can't tell what source file were used to compile the binary file from, or where in the file hierarchy they are located (not just where they were located when the binary file was compiled last time, maybe on another system).
You don't know the dependencies between the source code files. Makefiles are primarily useful for keeping track of these (and compiler flags etc.), so that changing one single source file in a big project does not trigger a recompilation of everything.
You don't know what compiler to use, or what flags to pass to it. This is another thing a Makefile contains.
There are build tools available for making the creation of Makefiles easier, and for making them portable between systems on different architectures (the Makefiles that is, not necessarily the programs, that's down to the programmer). One such set of tool is GNU's autotools, another is CMake, and I'm sure there are others as well, but those are the ones I use.
Now you're facing another but similar problem, and that is that you still need to learn the syntax of, and writ,e your Makefile.am and configure.ac files (for the GNU tools), or your CMakeLists.txt files (for CMake).

How can I completely compile a bash project to be distributed?

I am trying to compile a bash project into a distributable binary. I tried shc, and it worked, except all my source statements were broken. I have numerous source statements to keep the code base cleaner, but they are broken when compiled with shc. How can I compile down my bash project so that instead of having a bunch of .sh files, the end user can just have one single file?
Shc is an obfuscator, not a compiler. At the end of the day, it still invokes /bin/sh or whatever, and feeds it your original script. It has not a slightest idea what your script actually does. If it needs an additional file to source, you have to supply it at an appropriate location.
You may want to investigate things like SHAR. Build anarchive, then compile it with shc if you want.
It sounds like all you're missing is a facility to expand all your source statements. That should be fairly easy to write if your codebase is fairly consistent in its use of those statements: just write a script to expand them inline and away you go.
Alternatively, just put all your scripts into a single Zip file or tarball and tell the user to extract the contents of that one file, or if even that is too much I'm sure you can imagine a way to encode the zipped contents of all the non-main files into a giant comment at the bottom of the main file, and have it extract what it needs before proceeding.
Or, you know, use the appropriate installer for your system. Build an RPM for RHEL or a Debian package or a Windows MSI or whatever....

Make, install, executing a program

I have been a CS student for a while and it seems like I (or many of my friends) never understood what's happening behind the scene when it terms to make, install etc.
Correct me but is make a way to compile a set of files?
what is it mean by "installing a program to a computer" like on windows because when I am coding in different languages such as java or perl, we dont install what we wrote. we would compile (if not, interpret language) and just run it. So, why are programs such as Skype needs to be "installed"?
Can anyone clarify this? I feel like this is something i need to know as a programmer.
Make is a build system
Make is a build system which is simply a way to script the steps needed to compile a program. Make specifically can be used with anything, but is usually used to compile C or C++ programs. It simplifies and creates a standard way for programmers to script the preparation of their program, so that it can be built and installed with ease
Why a build system
You see, if your program is a simple one source file program, then using make might be an overkill, as compiling the simplest c program is as simple as
gcc simpleprogram.c -o simpleprogram.out
However, as the size of the software grows, the complexity of it grows, and the complexity of how it needs to be built grows. For example, you may want to determine which version of each library is installed in the computer which you are compiling in, you may want to run some tests after compiling your program to determine it is working correctly, or you may want to automatically download some dependencies your program has.
Most software built need a mixture of these tasks eventually. So, instead of reinventing the wheel, they use a build system which allow scripting this. If you are familiar with Java (which you mentioned) a build system comparable to make, but used in the java world is Apache Ant.
Why install
Well, lets assume that you used the "make" command but not "make install". The "make" command is usually used to just to prepare the program for compilation, and the compile it. However, once your program is compiled, all you have is an executable in the directory in which you compiled the program in. The program, its documentation, and it's configuration files haven't been put in the appropriate directories needed for all users to use it. That's what "make install" is for. Make install takes all the files associated with the program you just compiled, and puts said files in the appropriate directories, so that it becomes available to everyone, and so that each component is in the expected directory according to your operating system.
make is a bit of software that reduces the amount of code that needs to be compiled - it compares modification times of the source code with the target. If the code has changed a compile is done to construct the target otherwise you can skip that step.
Installing software is placing the executables/configuration files into the right places - perhaps constructing some files along the way. E.g. usernames in your skype example

OpenGL SDK How To Create New Projects With Premake

I have recently begun the process of learning OpenGL to start making some Graphical applications using C++. I have installed the OpenGL SDK and I am able to build the projects properly on that. However, on the OpenGL SDK site there is little to no information what-so-ever on how to create new projects using the elements of the SDK, such as freeglut etc. I have Premake 4.0 and I understand I have to do something with the lua files, I do not know lua however and am not sure how to use the Lua files to create a new project. So could you help me out? Im using VS2010, should I create the project, then do something with premake? Or create some sort of lua file, then use premake on that? Any help would be wonderful because I am very lost, and would really like to get started with OpenGL. I have experimented a lot with this, such as copying the lua files from the sdk, but that came with no luck.
If you are not familiar with Premake4, then I strongly advise you to just use Visual Studio projects directly. If you're having trouble with that, then please amend your question with exactly what you did, and exactly the error messages that Visual Studio gave you when attempting to build. You should include:
The include paths. The full set of include paths, including full absolute directory names (including the path of your project and solution files).
The static library search paths.
The static libraries you are including.
The defines you are building with.
Note: If you don't know what any of these are, then you need to stop and learn a lot more about how C++ projects work. You need to understand how compilers deal with include paths, static libraries, #defines, etc.
If you are not familiar with Premake4, and you still want to use Premake4 with the SDK, then you first must become familiar with Premake4 without the SDK. I could give you an entire premake4.lua script that you could just plug in, change a few lines, and everything would magically work (and if you want that, you could look at how the SDK's examples are built. Specifically examples/premake4.lua). But if I did that, you wouldn't learn anything. You'd just be copy-and-pasting code, without having the slightest understanding of how it works.
So instead, I'm going to tell you what steps you should take to learn how to use Premake4.
Step 1: Hello World, Premake-style. You should make a single .cpp file that is a Hello World application. It just has a standard main function that prints "Hello World" to the console. That's the easy part.
The hard part is the Premake4 script. Rather than creating a Visual Studio project directly, you are going to write a Premake4 script to build that project for you.
The Premake4 documentation can walk you through the steps of making your first solution and project. You will of course need to add files to that project. You should also learn how to use configurations, so that you can have a Debug and Release build. The Debug build should have symbols, and the Release build should be optimized.
Step 2: Multiple projects. Here, you have two .cpp files: test.cpp and main.cpp. In test.cpp, place a function that prints something. The function shouldn't take parameters or anything. In main.cpp, you should have the main function that calls the function defined in test.cpp. There should also be a test.h which has a prototype for the function defined in test.cpp.
The trick here is that you aren't compiling them into the same executable. Not directly. You want two projects: one named test and one named main. The test project should be a static library, which compiles test.cpp. The main project will be the actual executable, which compiles main.cpp. Both of them should include test.h in their file lists.
Here, you're learning that solutions can have multiple projects. The two projects have different file lists. Each project can have a separate kind, which determines the type of build for that project alone. The test project should be a StaticLib, while the main project should be a ConsoleApp.
You will also need to learn to use the links command to link them together. The main project should use links to specify test. test does not need to link to something.
Step 3: Mastering directories.
Here, you're going to do the same thing as Step 2. Except for one thing: put test.h and test.cpp in a different directory (a subdirectory of the current one). You also want a test.lua file in that directory, which you will execute from your main premake4.lua file with a dofile command. The test.lua is where you define your test project. You can call dofile on the test.lua file anytime after you have created the solution with the solution command.
Note that the main project will need to change the directory where it finds test.h. You will also need to use the includedirs command in the main project to tell the compiler where to search for the test.h header you include in main.cpp.
Step 4: Back to the SDK. At this point, you should now be familiar enough with Premake4 to look back at the instructions I pointed you to and understand them a bit better. Then, just do what the instructions say. When it tells you what the first line of your script should be, make that the first line of your script. Put the UseLibs function where it says to put them; it even gives you an example of where it goes. Think of UseLibs as a fancy combination of links and includedirs.

Automatically compile any Java class when the file is dropped in a directory

I look at a lot of small Java programs. It would be convenient if I could set up a directory (or directory structure) on my Mac where any time I add a .java file, javac automatically runs and attempts to compile that file. I've briefly looked into Automator actions, but found nothing that fits the bill. Then I got to thinking: on my PC, I would use the .Net FileSystemWatcher class and write the code myself. But before I try that on my Mac with Mono, I want to ask the community for other ideas. Any advice is appreciated. Thanks.
In JDK6 you can programmatically compile, so you could write your own program to do this, which may be slightly better than doing it in mono.
So you would just have a program that is always running, it looks for either any new files or a file that has been changed since the last check and then just compiles them, and you may want it to pass information to a dashboard window when there are errors, and perhaps some status info so you know it is working.
http://binkley.blogspot.com/2005/09/programmatically-compiling-java-in-jdk.html
If you have all the .java files available at the start, you could write a shell script to compile them all in one run -- in different directories if you need to.
If you explained why you would want this, maybe I/we could be more helpful.

Resources