Hi all,
I have a similar problem using command line to compile Fortran codes in OS X El Capitan, and I have followed the methods in this post. But after I update xcode, install command line tools and uninstall macports, the problem is still there. I tried with both f77 and gfortran.
The version of f77 is
~/Documents/autovp $f77 -v
/usr/local/bin/f77 script based on f2c:
f2c (Fortran to C Translator) version 20100827.
With f77, I get the following error:
f77 autofit.o ew_finder.o smooth.o fitregion.o model.o combine.o fitsat.o inparam.o readdata.o polyfit.o -o autofit
Undefined symbols for architecture x86_64:
"MAIN__", referenced from:
-u command line option
(maybe you meant: _MAIN__)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
f77 minfit.o minimize.o model.o ew_finder.o oneparmin.o tossline.o splitreg.o readdata.o initparm.o fixparm.o loadline.o funcs.o nparmin.o inparam.o polyfit.o piksrt.o piksr2.o addline.o getlines.o -o minfit
Undefined symbols for architecture x86_64:
"MAIN__", referenced from:
-u command line option
(maybe you meant: _MAIN__)
"_doublet2_", referenced from:
_MAIN__ in minfit.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My gfortran version is 5.2.0:
~/Documents/autovp $gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.2.0/lto-wrapper
Target: x86_64-apple-darwin14
Configured with: ../gcc-5.2.0/configure --prefix=/usr/local/gfortran --with-gmp=/Users/fx/devel/gcc/deps-static/x86_64 --enable-languages=c,c++,fortran,objc,obj-c++ --build=x86_64-apple-darwin14
Thread model: posix
gcc version 5.2.0 (GCC)
With gfortran -v, I get the following error:
f77 -c -o autofit.o autofit.f
autofit.f:
MAIN autofit:
Warning on line 34 of autofit.f: local variable gamma never used
Warning on line 34 of autofit.f: local variable ion_str never used
fappend:
f77 -c -o ew_finder.o ew_finder.f
ew_finder.f:
ew_finder:
Warning on line 123 of ew_finder.f: local variable id never used
f77 -c -o smooth.o smooth.f
smooth.f:
smooth:
smoothsat:
f77 -c -o fitregion.o fitregion.f
fitregion.f:
fitregion:
Warning on line 78 of fitregion.f: local variable lineflag never used
findmin:
fitline:
modelbelow:
f77 -c -o model.o model.f
model.f:
model:
model1:
cpf12:
f77 -c -o combine.o combine.f
combine.f:
combine:
Warning on line 57 of combine.f: local variable nl never used
f77 -c -o fitsat.o fitsat.f
fitsat.f:
fitsat:
Warning on line 50 of fitsat.f: local variable j never used
nhitest:
chisqr:
deconv:
Warning on line 169 of fitsat.f: local variable smallflux never used
Warning on line 169 of fitsat.f: local variable bigflux never used
f77 -c -o inparam.o inparam.f
inparam.f:
inparam:
f77 -c -o readdata.o readdata.f
readdata.f:
readdata:
Warning on line 57 of readdata.f: local variable k never used
len1:
f77 -c -o polyfit.o polyfit.f
polyfit.f:
polyfit:
Warning on line 88 of polyfit.f: local variable chisqold never used
Warning on line 88 of polyfit.f: local variable dvel never used
Warning on line 88 of polyfit.f: local variable hilim never used
Warning on line 88 of polyfit.f: local variable dwave never used
Warning on line 88 of polyfit.f: local variable nwrap never used
Warning on line 88 of polyfit.f: local variable sigmax never used
Warning on line 88 of polyfit.f: local variable lowlim never used
Warning on line 88 of polyfit.f: local variable fluxmax never used
funcpoly:
svdfit:
svdcmp:
svbksb:
/usr/local/gfortran/bin/gfortran -v autofit.o ew_finder.o smooth.o fitregion.o model.o combine.o fitsat.o inparam.o readdata.o polyfit.o -o autofit
Driving: /usr/local/gfortran/bin/gfortran -mmacosx-version-min=10.11.0 -v autofit.o ew_finder.o smooth.o fitregion.o model.o combine.o fitsat.o inparam.o readdata.o polyfit.o -o autofit -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=/usr/local/gfortran/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.2.0/lto-wrapper
Target: x86_64-apple-darwin14
Configured with: ../gcc-5.2.0/configure --prefix=/usr/local/gfortran --with-gmp=/Users/fx/devel/gcc/deps-static/x86_64 --enable-languages=c,c++,fortran,objc,obj-c++ --build=x86_64-apple-darwin14
Thread model: posix
gcc version 5.2.0 (GCC)
Reading specs from /usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.11.0' '-v' '-o' 'autofit' '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.2.0/:/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.2.0/:/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/
LIBRARY_PATH=/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0/:/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.11.0' '-v' '-o' 'autofit' '-shared-libgcc' '-mtune=core2'
/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin14/5.2.0/collect2 -dynamic -arch x86_64 -macosx_version_min 10.11.0 -weak_reference_mismatches non-weak -o autofit -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0 -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0/../../.. autofit.o ew_finder.o smooth.o fitregion.o model.o combine.o fitsat.o inparam.o readdata.o polyfit.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 5.2.0
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.11.0 -weak_reference_mismatches non-weak -o autofit -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0 -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0/../../.. autofit.o ew_finder.o smooth.o fitregion.o model.o combine.o fitsat.o inparam.o readdata.o polyfit.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld PROJECT:ld64-253.6
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
/usr/local/gfortran/lib/gcc/x86_64-apple-darwin14/5.2.0
/usr/local/gfortran/lib
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
"_d_lg10", referenced from:
_nhitest_ in fitsat.o
"_d_sign", referenced from:
_svdcmp_ in polyfit.o
"_do_fio", referenced from:
_MAIN__ in autofit.o
_ew_finder__ in ew_finder.o
_fitregion_ in fitregion.o
_deconv_ in fitsat.o
_readdata_ in readdata.o
"_do_lio", referenced from:
_model1_ in model.o
_combine_ in combine.o
_inparam_ in inparam.o
_readdata_ in readdata.o
_svdcmp_ in polyfit.o
"_e_rsfe", referenced from:
_readdata_ in readdata.o
"_e_rsle", referenced from:
_inparam_ in inparam.o
_readdata_ in readdata.o
"_e_wsfe", referenced from:
_MAIN__ in autofit.o
_ew_finder__ in ew_finder.o
_fitregion_ in fitregion.o
_deconv_ in fitsat.o
_readdata_ in readdata.o
"_e_wsle", referenced from:
_model1_ in model.o
_combine_ in combine.o
_readdata_ in readdata.o
_svdcmp_ in polyfit.o
"_f_clos", referenced from:
_MAIN__ in autofit.o
_ew_finder__ in ew_finder.o
_inparam_ in inparam.o
_readdata_ in readdata.o
"_f_open", referenced from:
_MAIN__ in autofit.o
_ew_finder__ in ew_finder.o
_inparam_ in inparam.o
_readdata_ in readdata.o
"_getarg_", referenced from:
_MAIN__ in autofit.o
"_i_len", referenced from:
_fappend_ in autofit.o
"_main", referenced from:
implicit entry/start for main executable
"_pow_dd", referenced from:
_nhitest_ in fitsat.o
"_pow_di", referenced from:
_polyfit_ in polyfit.o
"_s_cat", referenced from:
_fappend_ in autofit.o
"_s_cmp", referenced from:
_fappend_ in autofit.o
_readdata_ in readdata.o
"_s_copy", referenced from:
_fappend_ in autofit.o
"_s_rsfe", referenced from:
_readdata_ in readdata.o
"_s_rsle", referenced from:
_inparam_ in inparam.o
_readdata_ in readdata.o
"_s_stop", referenced from:
_MAIN__ in autofit.o
"_s_wsfe", referenced from:
_MAIN__ in autofit.o
_ew_finder__ in ew_finder.o
_fitregion_ in fitregion.o
_deconv_ in fitsat.o
_readdata_ in readdata.o
"_s_wsle", referenced from:
_model1_ in model.o
_combine_ in combine.o
_readdata_ in readdata.o
_svdcmp_ in polyfit.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [autofit] Error 1
Other settings of mine are:
- Mac OS X El Capitan 10.11.1
- Xcode 7.1
- ld64-253.6 (from "ld -v")
- Apple LLVM version 7.0.0 (clang-700.1.76) (from "cc -v")
When I type "as -v", it stuck by showing:
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1as -triple x86_64-apple-macosx10.11.0 -filetype obj -main-file-name - -target-cpu core2 -fdebug-compilation-dir /Users/madcpf/Documents/autovp -dwarf-debug-producer Apple LLVM version 7.0.0 (clang-700.1.76) -o a.out -
Does anyone have any suggestions about how to solve this problem?
Thank you so much!
Pengfei
在 2015年1月26日星期一 UTC-8下午4:50:36,FX写道: