Author Topic: projects  (Read 8343 times)

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
projects
« on: July 30, 2015, 05:20:09 am »
If the purpose of projects is to group associated programs into one bundle, why won't mine compile with a main program and a common file? (F95)

The main compiles and runs but it needs the common file to run correctly.

Roger

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #2 on: July 30, 2015, 03:39:25 pm »
Thanks. I did as the instructions said and got a message that might as well have been written in Sanscrit.

It seems as if both common.f95 and roger21.f95 compiled to .o versions but both were considered to be main and therefore failed.

I have no idea what to do about it.

Code
Cleaned "test1 - Debug"

-------------- Build: Debug in test1 (compiler: GNU Fortran Compiler)---------------

mingw32-gfortran.exe -Jobj\Debug\ -Wall  -g     -c D:\FORTRAN\COMMON.f95 -o obj\Debug\COMMON.o
mingw32-gfortran.exe -Jobj\Debug\ -Wall  -g     -c D:\FORTRAN\test1\main.f95 -o obj\Debug\test1\main.o
mingw32-gfortran.exe -Jobj\Debug\ -Wall  -g     -c D:\FORTRAN\ROGER21.F95 -o obj\Debug\ROGER21.o
mingw32-gfortran.exe  -o bin\Debug\test1.exe obj\Debug\COMMON.o obj\Debug\test1\main.o obj\Debug\ROGER21.o   
obj\Debug\ROGER21.o: In function `main':
D:/FORTRAN/ROGER21.F95:2: multiple definition of `main'
obj\Debug\test1\main.o:D:/FORTRAN/test1/main.f95:8: first defined here
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))


Roger
« Last Edit: July 30, 2015, 03:50:36 pm by rogerh »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: projects
« Reply #3 on: July 30, 2015, 04:16:36 pm »
Thanks. I did as the instructions said and got a message that might as well have been written in Sanscrit.

It seems as if both common.f95 and roger21.f95 compiled to .o versions but both were considered to be main and therefore failed.

I have no idea what to do about it.

Code
Cleaned "test1 - Debug"

-------------- Build: Debug in test1 (compiler: GNU Fortran Compiler)---------------

mingw32-gfortran.exe -Jobj\Debug\ -Wall  -g     -c D:\FORTRAN\COMMON.f95 -o obj\Debug\COMMON.o
mingw32-gfortran.exe -Jobj\Debug\ -Wall  -g     -c D:\FORTRAN\test1\main.f95 -o obj\Debug\test1\main.o
mingw32-gfortran.exe -Jobj\Debug\ -Wall  -g     -c D:\FORTRAN\ROGER21.F95 -o obj\Debug\ROGER21.o
mingw32-gfortran.exe  -o bin\Debug\test1.exe obj\Debug\COMMON.o obj\Debug\test1\main.o obj\Debug\ROGER21.o   
obj\Debug\ROGER21.o: In function `main':
D:/FORTRAN/ROGER21.F95:2: multiple definition of `main'
obj\Debug\test1\main.o:D:/FORTRAN/test1/main.f95:8: first defined here
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))


Roger

I suggest finding a site that supports your Compiler or FORTRAN; and, then posting your code and this build log there.
Ask that site for help in learning FORTRAN and/or how your Compiler works.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #4 on: July 30, 2015, 04:20:04 pm »
Thanks, that sounds reasonable.

Apparently it's not a C::B problem.

Unfortunately the last post on the mingw board was 4 years ago. I don't think that will help.

Also true of the other free compiler and the 3rd one is not free.

It's possible to merge it all into one file but that's not a good solution.

Roger
« Last Edit: July 30, 2015, 06:47:33 pm by rogerh »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: projects
« Reply #5 on: July 30, 2015, 08:57:32 pm »
The problem is that you have two main functions.
One in ROGER21.F95 and one in main.f95.

This is what the output is telling you.
Knowing this information you should be able to fix your problem.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #6 on: July 30, 2015, 09:30:17 pm »
Great.

Now it's complaining that main ISN'T in there.

Roger

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #7 on: July 30, 2015, 10:25:12 pm »
Ok everytime I try to start a new project, CB puts a main in it that gives me "Hello world." no matter what I do.

If I just compile my program it doesn't have the needed common module

Roger

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: projects
« Reply #8 on: July 31, 2015, 12:41:17 am »
FYI: I have absolute no idea about fortran, but i think at the compiling level it is the same as c...

Ok everytime I try to start a new project, CB puts a main in it that gives me "Hello world." no matter what I do.
Well, you simply can overwrite this code with your own, or you simply remove the pre created file from the project with a right click and remove file....

If I just compile my program it doesn't have the needed common module
Do you have any idea what a module is? Can you explain it to me (remember i have no idea about fortran)?
If you have compiler problems ALWAYS add a reabuild log with your post, because this is the only way we can try to get an idea about what is going on...

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #9 on: July 31, 2015, 01:56:14 am »
Well, you simply can overwrite this code with your own, or you simply remove the pre created file from the project with a right click and remove file....

That worked! Progress.

Quote
Do you have any idea what a module is? Can you explain it to me (remember i have no idea about fortran)?

Fortran used to have common blocks inside the program listing variables to be shared with the subroutines. Now they can be put in an external file and referenced in the program.

Quote
If you have compiler problems ALWAYS add a reabuild log with your post, because this is the only way we can try to get an idea about what is going on...

The problem now is getting the main into the project. CB has a strange way of handling the contents of a project.

Roger

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: projects
« Reply #10 on: July 31, 2015, 02:18:12 am »
I really dont get your problem and why you think c::b handles projects srrange. Keep in mind that c::b is not a compiler but a ide. Cb has no idea about your main and he doesn't have to. C::b feeds all files from a project (there are exceptions e.g. Targets ) to the compiler. If you have multiple mains over multiple files in one project, then you confuse the compiler, because a program can have only one start point. But this has nothing to do with c::b...

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #11 on: July 31, 2015, 02:33:46 am »
I really dont get your problem and why you think c::b handles projects srrange.

Well for example, when you ask it to add or remove files from a project it doesn't tell you what's there now.

Quote
Keep in mind that c::b is not a compiler but a ide. Cb has no idea about your main and he doesn't have to. C::b feeds all files from a project (there are exceptions e.g. Targets ) to the compiler. If you have multiple mains over multiple files in one project, then you confuse the compiler, because a program can have only one start point. But this has nothing to do with c::b...

No but cb puts a phony main in there without asking. It seems I have to call my program "main.f95"
so cb will understand, a point not mentioned in the docs.

If I seem rude please make allowances for the newness of all this.

Roger

Offline raynebc

  • Almost regular
  • **
  • Posts: 217
Re: projects
« Reply #12 on: July 31, 2015, 05:28:58 am »
To see the contents of the project, make sure View>Manager is checked and change that to the Projects tab.

Offline rogerh

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: projects
« Reply #13 on: July 31, 2015, 05:17:33 pm »
This is getting incredibly frustrating.

Is there a C::B for idiots somewhere?

I'm trying to create a new project. It should contain 2 files; roger21.f95 and common.f95.

Instead, CB puts a main.f95 file in there, causing an error (two mains).

If I delete the fake main and rename roger21.f95 to main.f95 CB puts the fake main back, overwriting my version.

It can't be this hard!!!

Roger

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7592
    • My Best Post
Re: projects
« Reply #14 on: July 31, 2015, 07:05:37 pm »
Is there a reason you think this site support learning FORTRAN?

Did you try this site? http://darmar.vgtu.lt/
Or the newer site http://cbfortran.sourceforge.net/

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org