- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to compile a code that works fine in windows. I am getting this error when it goes to create the executable.
ifort -O0 -g -auto -ansi_alias- -pad_source -traceback -fpconstant -nogen-interfaces \\
relap/relapd.a scdap/scdapd.a \\
matpro/matprod.a scdap/scdapd.a envrl/envrld.a \\
relap5l.dylib -o relap5d.x
Undefined symbols:
"_MAIN__", referenced from:
_main in for_main.o
ld: symbol(s) not found
make[1]: [relap5d.x] Error 1 (ignored)
ifort -O0 -g -auto -ansi_alias- -pad_source -traceback -fpconstant -nogen-interfaces \\ relap/relapd.a scdap/scdapd.a \\ matpro/matprod.a scdap/scdapd.a envrl/envrld.a \\ relap5l.dylib -o relap5d.xUndefined symbols:"_MAIN__", referenced from: _main in for_main.old: symbol(s) not foundmake[1]: [relap5d.x] Error 1 (ignored)I am running IFC 11.1.084 andI tried IFC 11.1.088
Link Copied
29 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the main program in Fortran or in another language? If in another language, add -nofor-main
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I fixed the for_main.o error and now I am getting this error:
ifort -logo
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100203 Package ID: m_cprof_p_11.1.084Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
if [ ! -d "d" ]; then mkdir "d"; fi
ls envrl/*.hh >filedoth
ls envrl/*.ff >filedotf
ls matpro/*.hh >filedoth
ls matpro/*.ff >filedotf
ls relap/*.hh >filedoth
ls relap/*.ff >filedotfls scdap/*.hh >filedoth
ls scdap/*.ff >filedotf
auxx/builderm.x makermacp
cd ..
make -f makrelap NM=d FFLAGS="-O0 -g" FPSTOP= \
O=obj cpl=
ifort -O0 -g -auto -ansi_alias- -pad_source -traceback -fpconstant -nogen-interfaces -nofor-main \
relap/relapd.a scdap/scdapd.a \
matpro/matprod.a scdap/scdapd.a envrl/envrld.a \
relap5l.dylib -o relap5d.x
Undefined symbols:
"_MAIN__", referenced from:
_main in libifcore.a(for_main.o)ld: symbol(s) not found
make[1]: [relap5d.x] Error 1 (ignored)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That looks like the same error. Where is your main program? Is it Fortran or is it in one of those libraries?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This was the error before I added the -nofor-main.
Undefined symbols:Undefined symbols:"_MAIN__", referenced from: _main in for_main.old: symbol(s) not found
This is the error I am getting now.
Undefined symbols:ndefined symbols:"_MAIN__", referenced from: _main in libifcore.a(for_main.o)ld: symbol(s) not found
They are different. The main program is fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, I think they are the same. Either you transcribed them wrong or your display was garbled. If the main program is in Fortran, then do not use -nofor-main. In which object is the main program? What do you get with a "nm -a" on that object?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I don't use the -nofor-main I get the error about the for_main.o file, if I use the -nofor-main then I get the error about thelibifcore.a(for_main.o).
I did not transcribe anything wrong. I cut and pasted the text from my look files. As far as the "main" program it is in my fortran files. What do you mean by nm -a on the object?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The errors are the same, but there are characters missing or garbled from the first one - at least in the reply a couple back.
I mean do:
nm -a mainprog.o
where mainprog.o is the object from compiling your main program. This will list the global symbols defined and used by that object.
I mean do:
nm -a mainprog.o
where mainprog.o is the object from compiling your main program. This will list the global symbols defined and used by that object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is what I got from the main program.
0000000000000000 T _MAIN__
00000000000afc90 C _alcm_
0000000000001410 C _balfar_
0000000000019920 C _bconds_
0000000000000790 C _bcons_
0000000000002b30 C _bder_
U _blkdat_
U _blkdt2_
U _blkdta_
0000000000001fd0 C _bln2wk_
00000000000007b0 C _bloona_
0000000000000150 C _bloonb_
000000000000a090 C _bloond_
0000000000000810 C _bsize_
0000000000001e20 C _buntim_
0000000000000070 C _bwcons_
0000000000017cd0 C _bwgeom_
0000000000019070 C _bwprop_
000000000002fc10 C _bwtrns_
000000000001e510 C _cdfinc_
0000000000001fa0 C _cdfinv_
0000000000000050 C _cmatp_
0000000000000020 C _cmptim_
0000000000000860 C _comctl_
0000000000000050 C _cons_
0000000000000310 C _contrl_
0000000000000290 C _coupl_
0000000000000020 C _cpmdat_
00000000000000b0 C _cprdat_
00000000000c31d0 C _dbacct_
0000000000012c10 C _debout_
0000000000006490 C _effprp_
0000000000000040 C _eht0_
0000000000000040 C _ehtc0_
000000000002a150 C _farays_
0000000001e84800 C _fast_
00000000000065c0 C _fecom_
0000000000000040 C _fginvc_
0000000000022410 C _fgrcom_
U _for_set_reentrancy
U _for_stop_core
0000000000001b90 C _fpbin_
00000000000021b0 C _fpcoef_
00000000000000b0 C _fpctrl_
0000000000000060 C _fpinsc_
0000000000000b10 C _fpinsh_
0000000000014050 C _fpmass_
0000000000000050 C _fpmdl_
0000000000007810 C _fpnonv_
0000000000000100 C _fpvol_
00000000000000d0 C _ftb_
0000000000000010 C _ftbfet_
00000000000000b0 C _genrl_
0000000000086650 C _grscgr_
0000000000000350 C _grsprg_
0000000000001020 C _hardpn_
0000000000000050 C _hfuson_
U _incond_
U _inputd_
0000000000041bd0 C _intcom_
0000000000000320 C _iparm_
00000000000001d0 C _k3all_
0000000000000300 C _k3point_
0000000000000030 C _lvel_
00000000000009c0 C _madatc_
0000000000001c20 C _matdat_
0000000000000020 C _matsrs_
0000000000000010 C _maxmem_
0000000000002c40 C _miscon_
0000000000000070 C _mxnfbv_
0000000000000e70 C _mxnfcv_
0000000000000020 C _nbtim_
0000000000001e90 C _ndxara_
0000000000011250 C _nhtara_
0000000000041cb0 C _nrcom_
00000000000000a0 C _oxcom1_
0000000000000020 C _oxcom2_
0000000000000020 C _oxcom3_
0000000000000350 C _parg_
00000000000001c0 C _parm_
0000000000001490 C _plndat_
0000000000000100 C _prdat_
0000000000005cf0 C _ptscom_
0000000000011850 C _radata_
0000000000000330 C _rgacct_
00000000000004b0 C _rmadac_
0000000000000390 C _rupt_
00000000000d12b0 C _scdcom_
0000000000000010 C _scddat_
000000000003c9c0 C _scdout_
00000000000016e0 C _scdpow_
0000000000000040 C _scntl_
0000000000019a50 C _slbcom_
0000000000007940 C _slumpv_
0000000000000040 C _solcom_
0000000000000240 C _statec_
0000000000000010 C _stcblk_
0000000000000030 C _std2xc_
0000000000000030 C _sth2xc_
U _strip_
00000000002239d0 C _tblsp_
0000000000000150 C _thplot_
U _trnctl_
0000000000006e90 C _trnot1_
000000000000f090 C _trnot2_
0000000000000f00 C _ufilef_
0000000000000030 C _ufiles_
0000000000021c20 C _uoxcom_
0000000000000030 C _vel_
00000000000c3500 C _virtul_
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. That tells me that _MAIN__ is defined in this object. Now, which file, named in your ifort command that does the linking, is this object?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
# Explicit Targets
relap5$(NM).x: envrl/envrl$(NM).a matpro/matpro$(NM).a \
relap/relap5.$O relap/relap$(NM).a scdap/scdap$(NM).a \
tpfh2o$(NM) tpfd2o$(NM) relap5l.dylib
$(f90) $(FFLAGS) $(FPSTOP) $(FL) -nofor-main \
relap/relap$(NM).a scdap/scdap$(NM).a \
matpro/matpro$(NM).a scdap/scdap$(NM).a envrl/envrl$(NM).a \
relap5l.dylib -o relap5$(NM).x
The relap/relap$(NM).a contains the main object deck. THe line relap/relap5.$O is the Main object or program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Take out -nofor-main.
I think I need a Linux expert to comment on this...
I think I need a Linux expert to comment on this...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the -nofor-main removed, I get a complaint about undefined symbols referenced from for_main.o.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brian,
I am confused, please help me. First, let's ignore the fact that this compiled on Windows. What we need to know is: Is the main program in C or Fortran? In C, I would expect
void main() {
..etc..
}
In Fortran:
PROGRAM Foo
...stuff..
end
OR for really old F77 code:
...stuff...
end
The linker is telling us that you don't have either a C or a Fortran main program. If C, -nofor-main should be used. If Fortran you don't need the option but you do need to provide the source file or object file that contains the PROGRAM.
thanks
ron
I am confused, please help me. First, let's ignore the fact that this compiled on Windows. What we need to know is: Is the main program in C or Fortran? In C, I would expect
void main() {
..etc..
}
In Fortran:
PROGRAM Foo
...stuff..
end
OR for really old F77 code:
...stuff...
end
The linker is telling us that you don't have either a C or a Fortran main program. If C, -nofor-main should be used. If Fortran you don't need the option but you do need to provide the source file or object file that contains the PROGRAM.
thanks
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is in Fortran. No C anywhere in our code. So, I will remove the -nofor-main line. I placed the object in IFORT line and I am getting all kinds of undefined symbols now.
Here is the IFORT line
ifort -O0 -g -auto -ansi_alias- -pad_source -traceback -fpconstant -nogen-interfaces \
relap/relapd.a scdap/scdapd.a matpro/matprod.a \
envrl/envrld.a relap/relap5.obj relap5l.dylib -o relap5d.x
The bold underline is the main program. The main program is also included in the relapd.a library found in the bold italic underlined. I think that is where the conflict is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are right: you should not put a main program in a static library, relapd.a. That is certain to cause problems. Get it out of there. If the main program is in relap5.obj that is OK, but it can't exist in 2 places and it should never be in a static or dynamic library.
ron
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok, so I pulled it out of the library and re-compiled. I am still getting undefined symbols.
ifort -O0 -g -auto -ansi_alias- -pad_source -traceback -fpconstant -nogen-interfaces relap/relap5.obj \
relap/relapd.a scdap/scdapd.a matpro/matprod.a \
envrl/envrld.a relap5l.dylib -o relap5d.x
Undefined symbols:
"_jundat_mp_njunsj_", referenced from:
_imlp_ in relapd.a(imlp.obj)
_imlp_ in relapd.a(imlp.obj)
"_voldat_mp_volclear_", referenced from:
_gninit_ in relapd.a(gninit.obj)
"_voldat_mp_vol_", referenced from:
_imlp_ in relapd.a(imlp.obj)
_imlp_ in relapd.a(imlp.obj)
_imlp_ in relapd.a(imlp.obj)
...... and so on.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
looks like we're making some progress. Let me help to unravel the symbol names and maybe that can help you find the missing symbols or code:
"_valdat_mp_volclear_"
This symbol and the others with similar names are comprised of:
_mp_
So, there is somewhere in your code: MODULE VOLDAT
and in that module is a subroutine or function or data named VOLCLEAR.
When you compile the source for VOLDAT, you get a .mod file which is used to define the interface for VOLDAT and you get a .o file with the actual code (this is greatly simplified but hopefully helpful).
Now, in relapd there is a subroutine or function named GNINIT. It probably has
USE VOLDAT
SO - when you link, you need to add the .o file that you got when you compiled the source with VOLDAT or add that .o to one of your .a files already in the compile/link command
ron
"_valdat_mp_volclear_"
This symbol and the others with similar names are comprised of:
So, there is somewhere in your code: MODULE VOLDAT
and in that module is a subroutine or function or data named VOLCLEAR.
When you compile the source for VOLDAT, you get a .mod file which is used to define the interface for VOLDAT and you get a .o file with the actual code (this is greatly simplified but hopefully helpful).
Now, in relapd there is a subroutine or function named GNINIT. It probably has
USE VOLDAT
SO - when you link, you need to add the .o file that you got when you compiled the source with VOLDAT or add that .o to one of your .a files already in the compile/link command
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you think that I may need to adjust my archiving?
matpro/matpro$(NM).a: $(OBJSM)
ar r matpro/matpro$(NM).a $?
ranlib -c matpro/matpro$(NM).a
relap/relap$(NM).a: $(OBJSR)
ar r relap/relap$(NM).a $?
ranlib -c relap/relap$(NM).a
scdap/scdap$(NM).a: $(OBJSS)
ar r scdap/scdap$(NM).a $?
ranlib -c scdap/scdap$(NM).a
The undefined symbols error is happening for everything in my .a files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the archive and ranlib look fine for Mac OS.
Let's try to find our friend valdat_mp_volclear. Try this:
nm */*.a | grep -i valdat_mp_volclear
this will find all occurences of valdat_mp_volclear in your libraries. If you know what library that should be, you could simplify to:
nm relap/relap5.a | grep -i valdat_mp_volclear
What we want to see: We want to find all undefined references flagged with "U " in the nm output. Ideally we want to find 1 place where it is a target (or defined). nm flags these as "T " in the output. For module data, we expect nm to flag those as "C ".
nm foo.a
foo.a(module_foo.o):
0000000000000402 s EH_frame0
0000000000000402 s L_fde_cie_0
00000000000000d4 d STRLITPACK_0
00000000000000c4 d STRLITPACK_1.0.3
00000000000000cc d STRLITPACK_2.0.3
00000000000000b6 T _foo._
00000000000004a2 S _foo._.eh
0000000000000190 C _foo_mp_myarray_ <<< this is real :: my array(100) in the module
0000000000000000 T _foo_mp_rfunc_ <<< this is a module procedure 'rfunc'
000000000000041a S _foo_mp_rfunc_.eh
000000000000001c T _foo_mp_sub1_ <<< is is subroutine "sub1"
0000000000000452 S _foo_mp_sub1_.eh
What we want to look for is valdat_mp_volclear in your libraries, as either "T " or "C ". And once it's found, whether it's upper or lower case, and whether it has leading and trailing underscores.
If we find that one symbol defined, maybe we can figure out what is going on. IF you cannot find it as "T" or "C" but only as undefined "U", then we need to figure out why the .o file from the module containing valdat_mp_volclear is not getting included into the library.
ron
Let's try to find our friend valdat_mp_volclear. Try this:
nm */*.a | grep -i valdat_mp_volclear
this will find all occurences of valdat_mp_volclear in your libraries. If you know what library that should be, you could simplify to:
nm relap/relap5.a | grep -i valdat_mp_volclear
What we want to see: We want to find all undefined references flagged with "U " in the nm output. Ideally we want to find 1 place where it is a target (or defined). nm flags these as "T " in the output. For module data, we expect nm to flag those as "C ".
nm foo.a
foo.a(module_foo.o):
0000000000000402 s EH_frame0
0000000000000402 s L_fde_cie_0
00000000000000d4 d STRLITPACK_0
00000000000000c4 d STRLITPACK_1.0.3
00000000000000cc d STRLITPACK_2.0.3
00000000000000b6 T _foo._
00000000000004a2 S _foo._.eh
0000000000000190 C _foo_mp_myarray_ <<< this is real :: my array(100) in the module
0000000000000000 T _foo_mp_rfunc_ <<< this is a module procedure 'rfunc'
000000000000041a S _foo_mp_rfunc_.eh
000000000000001c T _foo_mp_sub1_ <<< is is subroutine "sub1"
0000000000000452 S _foo_mp_sub1_.eh
What we want to look for is valdat_mp_volclear in your libraries, as either "T " or "C ". And once it's found, whether it's upper or lower case, and whether it has leading and trailing underscores.
If we find that one symbol defined, maybe we can figure out what is going on. IF you cannot find it as "T" or "C" but only as undefined "U", then we need to figure out why the .o file from the module containing valdat_mp_volclear is not getting included into the library.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is what I found.
U _voldat_mp_vol_

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page