Executing .o-Files (dont know their name)
Hi everybody!
I hope you can help me. I don't know how to discribe this but I am going to try: I have a fortran file (.for) and a compiled (.o) version of the same program. The program is just a program that takes 2 parameters and returns a number. This should be called in console (bash) like "program.o(2.4,3.5)". I don't want to use a compiler. How can this be done? Thanks for any hint! Edit: I just recognized that there is a .a-File with the .o-Files inside. Is this the file to call? |
Quote:
Or, from anywhere in the directory tree, give the full path to the program followed by the inputs. |
Thanks, but that doesn't work, I get "command not found" error in bash.
Can I call the Archive (.a-file) with the program inside (as .o-File)? Is there a good doc/howto for .a-files to use from bash? Thanks! |
I dont think you can run an object file the file has to be linked and an ELF executable created before you can run it.
|
And how can I do that?
|
You should use a linker (see man ld for details) and specify the location of the fortran libraries and all the shared libraries used. Better to do the compilation again with your fortran compiler, since it takes care of this last step (linking object files and shared libraries together) automatically, unless you specify the -c option. Anyway, how did you obtain a .o file?
|
The compiling is not the problem. I just wanted to know how to use just the .o files or the static library (thats how the a-file is called) from out the bash. What if the .for files are missing? Do I really have to run a compiler again? Is there no other way?
|
I am playing with the thought to open up a new thread with the title: Using programs inside static libraries from out bash.
I had no idea before opening this thread that the .a file is such a library with object files inside. I am sorry that this is a bad approach but I had also no idea where to start to ask. Thanks for helping me! Edit: And I read through the ld manual, but still dont know what to do with that. |
What Fortran complier are you using?
Typically if you want to compile hello.for: g77 hello.for your executable file name will be named a.out g77 -o hello hello.for your executable file will be named hello (no extension required) g77 -c hello.for will create the object file hello.o To run the program assuming it is not in the users path environment type in: ./hello |
Normally its
prog.for - src file prog.o - compiled object file: note you can't run this prog (or prog.exe on some OSes) runnable exe after 'linking' the object file(s) and any reqd libs stuff.a - static lib file to be linked to your progs as needed Generally most compilers default to compiling and linking in one go, unless you specify compile only. YMMV To run it, specify path & name /home/me/prog or (if I'm in that dir already) ./prog |
All times are GMT -5. The time now is 05:45 PM. |