Thread: "Cant find main" linking fortran with c++

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    5

    Question "Cant find main" linking fortran with c++

    I am trying to call a C routine (which uses C++ libraries) from a Fortran main program. To deal with the name mangling i need to link with a c++ linker. I've done this before, and it worked. But now I keep getting told "Cannot find main". Can't work out what I'm doing differently to before. Can anyone help?


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    How about a clue as to which compiler set you're using?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    5
    The fortran routines were compiled with Intel8 (ifort) compiler. And I am trying to link with g++. The only difference before when it worked was I was using Intel 7 instead of 8.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well that sure is gonna make it tough.
    It's hard enough when all the tools come from the same place, then at least there is a change that naming and calling conventions are consistent.

    Ever thought of using the G77 Fortran compiler from GNU?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    5
    I may try that to see if it works. In the long term I will need to use the Intel8 for speed.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    My other suggestion would be to use the 'nm' tool to explore the symbol names which are inside the various object files produced.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Try making a C main() and converting your Fortran program into a function.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Replies: 5
    Last Post: 04-16-2004, 01:29 AM
  3. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  4. Linking Fortran procedures with C program
    By gest in forum C Programming
    Replies: 5
    Last Post: 07-14-2003, 12:35 PM
  5. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM