Results 1 to 7 of 7

Thread: Undefined reference to MAIN

  1. #1
    Join Date
    Apr 2010
    Posts
    214

    Undefined reference to MAIN

    I might as well institute by saying that I am a total to programming, thus my tribulations might seem preposterous to the majority of you. Anyway, I am trying to accumulate an executable from src for the predetermined element code CalCulix, additional than continuously get the error. As I am using the ifort compiler I had to try to transform the create file which formerly used: g77 -Warn -O which I interpret into: ifort -warn unused –warn pronouncement -O2 I have in addition tried to utilize the flags: -nus -names as_is excluding no change. I need some help here.

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    Re: Undefined reference to MAIN

    I have encompassed and solved the tribulations (at least for at present) by using the -c compiler instruction when compiling the personality subprograms: ifort -O2 -i8 -r8 -assume byterecl -c -nodefaultlibs.for Then I accumulate the .o files:ifort -O2 -i8 -r8 -assume byterecl. Whether this is accurate merely time determine to tell as I am debugging at present. I be able to confirm that my program has regarding 20 files by means of routines and merely one most important program. What I gathered from the error communication I got the compiler was looking for a MAIN__ program in the defaulting directories consequently the reference to/src/libfor/for_main.c.

  3. #3
    Join Date
    May 2009
    Posts
    529

    Re: Undefined reference to MAIN

    No, there is no "compilation" being completed by means of this command. The compiler parses the point of view given to it, become aware of that no source files were individual, and hands in excess of the task to the linker. In fact, .o files consequence from a compilation, and not be able to be compiled the entire in excess of again for the reason that they are not FORTRAN source files. I encompass no for_main.c program and encompass no clue where this reference comes from. The compiler run-time starts in a C most important program, which does a number of settings up and then calls your FORTRAN most important. The object for_main.o is part of the compiler runtime, and includes a reference to MAIN__ which, if you do not make available the object file resulting from compiling a FORTRAN most significant program, remains unsatisfied.Given that the entire your source code is in FORTRAN.

  4. #4
    Join Date
    May 2009
    Posts
    637

    Re: Undefined reference to MAIN

    The tribulations are that f2c requirements to connection to the MAIN__ function which is the "Fortran main". It seems that it is immediately a dummy function call. And the fix is quite straightforward. This command line does not seem to have encompassed several "main Fortran program" as a source ('.f'?) or an object ('.o') file, the 'prep_chem_sources.a' be obliged to be an archive (for self-made objects obligatory in the submission), the '.a' frequently means a library (archive). So it includes only 'programs' (routines/functions) which the old FORTRAN language discernible as 'SUBROUTINE's. The most important FORTRAN program did not encompass this row in its beginning.

  5. #5
    Join Date
    May 2009
    Posts
    543

    Re: Undefined reference to MAIN

    I am innovative to FORTRAN additional than I have encompassed a superior background in programming. OK, so right at present I am using GFortran for the compiler (determine to switch to Lahey soon).I am having difficulties by means of modules Add the -c alternative to the command line. This determine to cause gfortran to engender the .mod and .o files, and it determine to suppress linking. You necessitate to add the .o file from the preceding command to this command. What you desire is something similar to gfortran.exe -c testMod.f90 gfortran.exe testMod_man.f90 testMod.o.

  6. #6
    Join Date
    May 2008
    Posts
    2,792

    Re: Undefined reference to MAIN

    This is approximately identical to what occurs in the majority languages and compilers if you try to link an executable program without having the entire the pieces. I am to some extent surprised that you do not be familiar with it if you have a superior background in programming, additional than perhaps incredible threw you off. It is, I have the same opinion, a bit counter-intuitive that the majority compilers by defaulting in addition try to link unless you explicitly tell them not to, additional than that is the usual scheme.

  7. #7
    Join Date
    May 2008
    Posts
    2,389

    Re: Undefined reference to MAIN

    The entire in excess of again, immediately similar to most compilers for most languages, when you do in conclusion link, you necessitate to tell the linker to comprise several previously compiled object files. Modules are not several dissimilar from anything else in this method. The USE statement tells the compiler to give the impression of being for the .mod file (well, that's the usual accomplishment choice), which has information in sequence used at compile time. Additional than the USE statement does not have encompassed anything to do by means of linking. If you encompass multiple object files to link, you necessitate specifying them the entire, immediately similar to you would for things additional than modules.

Similar Threads

  1. 'DOMParser is undefined' IE7 error message
    By Protectors in forum Technology & Internet
    Replies: 5
    Last Post: 28-01-2012, 08:20 AM
  2. Differences between int main() and int main(void)
    By BOGUMIL in forum Software Development
    Replies: 5
    Last Post: 10-06-2011, 06:55 AM
  3. Internet Explorer 8: comscore is undefined
    By Disha N in forum Technology & Internet
    Replies: 4
    Last Post: 13-02-2011, 10:34 AM
  4. Error: Use of undefined constant in PHP
    By amadeo in forum Software Development
    Replies: 3
    Last Post: 13-07-2009, 06:07 PM
  5. Undefined variable error in Php
    By Capers in forum Software Development
    Replies: 3
    Last Post: 31-03-2009, 05:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,229,246.11157 seconds with 17 queries