Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29274 Discussions

linking Problems: /opt/intel/fc/9.0/lib/for_main.o(.text+0x0):./src/libfor/for_main.c ...

lliechte
Beginner
1,546 Views

Hi,
I have a problem linking a mixed c/fortran code:
Here is the error message:

ifort -oBin/field.exe Objects/menu_transformations.o Objects/menu_visualizations.o Objects/dummy_hdf.o Objects/u_functions.o Objects/u_menu.o Objects/u_menu_main.o Objects/diff_op_w2d.lib.o Objects/init_w2dlap_filt.o Objects/init_w2drec_filt.o Objects/simulations_w2d.lib.o Objects/init_w1dint_filt.o Objects/init_w2dpois_filt.o Objects/mask.lib.o Objects/w_t_adapt_2dw.lib.o Objects/fftw3.o Objects/main.o Objects/field.o Objects/gnuplot.o Objects/palette.o Objects/ppm.o Objects/dx.o Objects/input_bin.o Objects/input_output.o Objects/slave.o -lfftw3 -LSources/Field_includes/fftw/lib/ -lm
Objects/main.o(.text+0x0): In function `main':
main.c: multiple definition of `main'
/opt/intel/fc/9.0/lib/for_main.o(.text+0x0):./src/libfor/for_main.c: first defined here
ld: Warning: size of symbol `main' changed from 76 in /opt/intel/fc/9.0/lib/for_main.o to 47 in Objects/main.o
/opt/intel/fc/9.0/lib/for_main.o(.text+0x39): In function `main':
./src/libfor/for_main.c: undefined reference to `MAIN__'
gmake: *** [Bin/field.exe] Error 1

The file Objects/main.o is created with gcc:

gcc -c -IInclude -oObjects/main.o Sources/main.c

No error messages or warnings here.

Thank you for help.
Luke

0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,546 Views
Add to the ifort command -nofor_main
0 Kudos
lliechte
Beginner
1,546 Views
Thanks, it works.
0 Kudos
brunno_goldstein
Beginner
1,546 Views
Add to the ifort command -nofor_main

Steve, i had the same problem but my Program is in Fortran code only. I'm using eclipse 3.4 with intel fortran compiler professional edition v.11 .

Any Idea?

output :

Building target: NewSar2009
Invoking: Intel Fortran Linker
ifort -o"NewSar2009" ./EasyTools.o ./LinuxShell.o ./Main.o ./Sarinv/calccut.o ./Sarinv/calibra.o ./Sarinv/cfftb.o ./Sarinv/cfftf.o ./Sarinv/cffti.o ./Sarinv/chasar.o ./Sarinv/costp.o ./Sarinv/fft.o ./Sarinv/forward.o ./Sarinv/fttok.o ./Sarinv/gen_para.o ./Sarinv/grid_para.o ./Sarinv/grid_setup.o ./Sarinv/iecf_len.o ./Sarinv/imaging_para.o ./Sarinv/interfaces.o ./Sarinv/invert.o ./Sarinv/isoplot.o ./Sarinv/julian.o ./Sarinv/neg_cmplx.o ./Sarinv/neg_real.o ./Sarinv/newspec.o ./Sarinv/rdcollidx.o ./Sarinv/rdgenpar.o ./Sarinv/rdindpar.o ./Sarinv/rdsardate_ers1.o ./Sarinv/rdsarspec_ers1.o ./Sarinv/readwsp.o ./Sarinv/relmax.o ./Sarinv/sarinv.o ./Sarinv/select.o ./Sarinv/stepinfo.o ./Sarinv/uwafilter.o ./Sarinv/variance.o ./Sarinv/waven.o ./Sarinv/wrcollidx.o ./Sarinv/wrires.o ./Sarinv/wtail.o ./Partinv/correl.o ./Partinv/crossas2.o ./Partinv/leastsquare.o ./Partinv/partout2.o ./Partinv/pythag.o ./Partinv/svdcmp.o ./Partinv/swellsep.o ./Partinv/tustre2_wkst.o ./Findbest/findbest.o
ld: /lib/for_main.o: No such file: No such file or directory
make: ** [NewSar2009] Erro 1
make: O alvo `all' no foi reprocessado por causa de erros.

Thank you!
0 Kudos
Ron_Green
Moderator
1,546 Views

Steve, i had the same problem but my Program is in Fortran code only. I'm using eclipse 3.4 with intel fortran compiler professional edition v.11 .

Any Idea?

output :

Building target: NewSar2009
Invoking: Intel Fortran Linker
ifort -o"NewSar2009" ./EasyTools.o ./LinuxShell.o ./Main.o ./Sarinv/calccut.o ./Sarinv/calibra.o ./Sarinv/cfftb.o ./Sarinv/cfftf.o ./Sarinv/cffti.o ./Sarinv/chasar.o ./Sarinv/costp.o ./Sarinv/fft.o ./Sarinv/forward.o ./Sarinv/fttok.o ./Sarinv/gen_para.o ./Sarinv/grid_para.o ./Sarinv/grid_setup.o ./Sarinv/iecf_len.o ./Sarinv/imaging_para.o ./Sarinv/interfaces.o ./Sarinv/invert.o ./Sarinv/isoplot.o ./Sarinv/julian.o ./Sarinv/neg_cmplx.o ./Sarinv/neg_real.o ./Sarinv/newspec.o ./Sarinv/rdcollidx.o ./Sarinv/rdgenpar.o ./Sarinv/rdindpar.o ./Sarinv/rdsardate_ers1.o ./Sarinv/rdsarspec_ers1.o ./Sarinv/readwsp.o ./Sarinv/relmax.o ./Sarinv/sarinv.o ./Sarinv/select.o ./Sarinv/stepinfo.o ./Sarinv/uwafilter.o ./Sarinv/variance.o ./Sarinv/waven.o ./Sarinv/wrcollidx.o ./Sarinv/wrires.o ./Sarinv/wtail.o ./Partinv/correl.o ./Partinv/crossas2.o ./Partinv/leastsquare.o ./Partinv/partout2.o ./Partinv/pythag.o ./Partinv/svdcmp.o ./Partinv/swellsep.o ./Partinv/tustre2_wkst.o ./Findbest/findbest.o
ld: /lib/for_main.o: No such file: No such file or directory
make: ** [NewSar2009] Erro 1
make: O alvo `all' no foi reprocessado por causa de erros.

Thank you!

Steve is out at the Intel Developer Forum (IDF) in San Francisco this week, so I'll take a stab at this.

My guess is that Eclipse is not searching the library path to the Intel Fortran compiler libraries. Prior to starting Eclipse, do you 'source /opt/intel/.... ifortvars.sh' - perhaps put that into your .bashrc file to make sure LD_LIBRARY_PATH includes the Intel library path. Now if you are doing this, perhaps eclipse is ignoring LD_LIBRARY_PATH. Is there some linker setting that allows you to specify additional library paths? If so, add the path to the /lib directory for your compiler.

ron
0 Kudos
brunno_goldstein
Beginner
1,546 Views

Steve is out at the Intel Developer Forum (IDF) in San Francisco this week, so I'll take a stab at this.

My guess is that Eclipse is not searching the library path to the Intel Fortran compiler libraries. Prior to starting Eclipse, do you 'source /opt/intel/.... ifortvars.sh' - perhaps put that into your .bashrc file to make sure LD_LIBRARY_PATH includes the Intel library path. Now if you are doing this, perhaps eclipse is ignoring LD_LIBRARY_PATH. Is there some linker setting that allows you to specify additional library paths? If so, add the path to the /lib directory for your compiler.

ron

Thanks for fast help Ronald.

I did the command 'source /opt/intel...ifortvars.sh intel64' after the installation but i'm not sure that i put it in my .bashrc file. I need to edit it and add what exectaly?

Sorry for my reckless and poor information. =/

Brunno
0 Kudos
brunno_goldstein
Beginner
1,546 Views

Thanks for fast help Ronald.

I did the command 'source /opt/intel...ifortvars.sh intel64' after the installation but i'm not sure that i put it in my .bashrc file. I need to edit it and add what exectaly?

Sorry for my reckless and poor information. =/

Brunno

Ronald, seems like the problem is with eclipse. I add the LD_LIBRARY_PATH to the .bashrc file and now i can compile the program via command line but with eclipse it's the same problem. I'm going to try the second thing you said...

Thanks for all!
0 Kudos
brunno_goldstein
Beginner
1,546 Views

Ronald, seems like the problem is with eclipse. I add the LD_LIBRARY_PATH to the .bashrc file and now i can compile the program via command line but with eclipse it's the same problem. I'm going to try the second thing you said...

Thanks for all!
To solve the problem with eclipse and lib do this in eclipse:

Go to Run As -> Environment -> New
Then put,
Name : LD_LIBRARY_PATH
Value: "your lib path":$LD_LIBRARY_PATH

In my case was:
Value: /opt/intel/Compiler/11.1/046/lib/intel64:$LD_LIBRARY_PATH

Thanks again Ronald!
0 Kudos
Reply