gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1566 Posts in 517 Topics by 752 Members - Latest Member: zaikunzhang October 28, 2021, 12:01:27 AM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Linux  |  Compile Error
gfx
gfxgfx
 

Author Topic: Compile Error  (Read 1382 times)

siddique

  • Newbie
  • *
  • Posts: 4
Compile Error
« on: January 08, 2021, 05:52:12 PM »
Absoft Fortran 2019 for Linux.

I am getting an error when compiling any FORTRAN code

error           ERROR            ld returned 1 exit status

when i click right button and go to error it pops-up with a message
Cannot open file ..../collect2

File does not exist.

Thanks
« Last Edit: January 08, 2021, 05:53:59 PM by siddique »

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
Re: Compile Error
« Reply #1 on: January 08, 2021, 07:27:56 PM »
AbsoftTools is not able to interpret linker errors in the same way it does Fortran syntax errors reported by the compiler. You will need to examine the output in the Build window to determine the build failure, starting at the end of the output and working backward.

One of the most common link-time errors is an unresolved reference to an external subroutine.
In this case, the output in the Build window will look something like this:


f95   "./Release/main.o"   -o "./project" -IPA:debug=on -IPA:source_pu_order=on  -m64 -O2
./Release/main.o: In function `MAIN__':
(.text+0x24): undefined reference to `calc_routine_'
collect2: ld returned 1 exit status
link reported errors.
amake2: **** Error code 1 (continuing)
amake2: `all' not remade because of errors.
Build interrupted


If you are on a Debian based system, you may be getting a bad relocation error because the default on these systems is to create position independent executable programs. The error in the build output for this case will look something like:


/usr/bin/ld: ./Release/main.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
link reported errors.
Build interrupted

To solve this issue, you can turn on the "No PIE" option in the Linker page of the AbsoftTools Project Options dialog.

If you need further assistance, email Absoft support and provide the output from the Build window as well as the name and version of the Linux distribution you running on your system.



« Last Edit: January 08, 2021, 07:51:00 PM by forumadmin »

siddique

  • Newbie
  • *
  • Posts: 4
Re: Compile Error
« Reply #2 on: January 11, 2021, 06:18:30 PM »
Thanks a lot for your suggestions. I checked the option No PIE in the Linker tab of Project options and the problem is solved now.

siddique

  • Newbie
  • *
  • Posts: 4
Re: Compile Error
« Reply #3 on: January 11, 2021, 08:03:24 PM »
I am having compile issue for this simple code

PROGRAM main
IMPLICIT NONE

print*, "Random Number", rand()

end PROGRAM main

error IMPLICIT NONE is specified in the local scope, therefore an explicit type must be specified for function "RAND"

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
Re: Compile Error
« Reply #4 on: January 11, 2021, 08:51:26 PM »
The RAND function is supplied as part of Absoft's Unix Fortran compatibility library. Although this library is automatically linked, the routines it contains are not intrinsic functions.  As a result, you need to provide a type declaration if you include an IMPLICIT NONE statement. Also, the RAND function requires an integer argument. Here is a corrected version of your small example:

   PROGRAM main
   IMPLICIT NONE
   REAL(KIND=4) :: rand
   print*, "Random Number", rand(0)

   end PROGRAM main

You will find the documentation on RAND and the Unix Fortran library routines in the file /opt/absoft19.0/documentation/SupportLibrary.pdf.  The documentation for RAND begins at the bottom of page 26.

siddique

  • Newbie
  • *
  • Posts: 4
Re: Compile Error
« Reply #5 on: January 12, 2021, 04:43:34 PM »
Thanks a lot

Absoft User Forum  |  Support  |  Linux  |  Compile Error
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!