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

Undefined symbols for architecture x86_64

changks888
Beginner
3,207 Views
Greetings~
I am trying to compile a program with the NetCDF library.
The environment variable settings in makefile look like:
F77 = ifort
F77_OPTIONS = -O2 -132
INCLUDE_DIRS = -I/usr/local/include
LD_OPTIONS_NETCDF = /usr/local/lib/libnetcdf.a
When making the installation, I have the errors as below showed.
What is "Undefined symbols for architecture x86_64" stand for?
How to solve the errors?
Thanks.
Michael
=================
ifort biogeochem.o canopy.o climate.o diagnostics.o ies-io.o \\
initial.o io.o main.o math.o physiology.o radiation.o \\
readpars.o snow.o soil.o stats.o utilities.o vegetation.o weather.o \\
-O2 -real_size 64 -integer_size 64 -132 -heap-arrays -arch x86_64 -I/usr/local/include /usr/local/lib/libnetcdf.a -o ibis
Undefined symbols for architecture x86_64:
"_nf_create_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
"_nf_strerror_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
_inivar_ in ies-io.o
_endini_ in ies-io.o
_writevar_ in ies-io.o
_readvar_ in ies-io.o
_inird_ in io.o
...
"_nf_put_att_text_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
_inivar_ in ies-io.o
_wrestart_ in io.o
_wyearly_ in io.o
"_nf_def_dim_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
"_nf_def_var_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
_inivar_ in ies-io.o
"_nf_enddef_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
_inivar_ in ies-io.o
"_nf_put_var_real_", referenced from:
_inifile_ in ies-io.o
_inifilec_ in ies-io.o
"_nf_put_var_text_", referenced from:
_inifilec_ in ies-io.o
"_nf_redef_", referenced from:
_inivar_ in ies-io.o
"_nf_inq_dimid_", referenced from:
_inivar_ in ies-io.o
"_nf_put_att_real_", referenced from:
_inivar_ in ies-io.o
"_nf_close_", referenced from:
_endini_ in ies-io.o
_writevar_ in ies-io.o
_readvar_ in ies-io.o
"_nf_open_", referenced from:
_writevar_ in ies-io.o
_readvar_ in ies-io.o
_inird_ in io.o
"_nf_inq_varid_", referenced from:
_writevar_ in ies-io.o
_readvar_ in ies-io.o
_inird_ in io.o
"_nf_inq_varndims_", referenced from:
_writevar_ in ies-io.o
_readvar_ in ies-io.o
"_nf_put_vara_real_", referenced from:
_writevar_ in ies-io.o
"_nf_put_vara_text_", referenced from:
_writevar_ in ies-io.o
"_nf_get_vara_real_", referenced from:
_readvar_ in ies-io.o
"_nf_inq_vartype_", referenced from:
_readvar_ in ies-io.o
"_nf_get_att_text_", referenced from:
_inird_ in io.o
ld: symbol(s) not found for architecture x86_64
make: *** [ibis] Error 1
bash-3.2$
=================
0 Kudos
3 Replies
Ron_Green
Moderator
3,207 Views
First, let us assume that you want to build for 64bit applications, correct?

There are 2 compilers that come with your package, a 32bit and a 64bit compiler.
You set the 32bit compiler with:
source /opt/intel/bin/compilervars.sh ia32

You set the 64bit compiler with:
source /opt/intel/bin/compilervars.sh intel64

With the Intel Fortran for Mac OS X, you can also use
-m32 for 32bit object creation
-m64 for 64bit object creation

Which of these did you do before ies.o was built? To check, use the 'file' command:

file

examples:
rwgreen-mac02:~ rwgreen$ ifort -c -m32 deadbeef.f90
rwgreen-mac02:~ rwgreen$ file deadbeef.o
deadbeef.o: Mach-O object i386

rwgreen-mac02:~ rwgreen$ ifort -c -m64 deadbeef.f90
rwgreen-mac02:~ rwgreen$ file deadbeef.o
deadbeef.o: Mach-O 64-bit object x86_64

What the error is telling you is that ies.o may either have been build for i386 32bit OR there was perhaps some errors in building libnetcdf.a as there are missing symbols ( this means that several of the subroutines that should be in that library are not there - did you check your log file for the build of netcdf to see if there were some source files that did not compile properly? ) In particular, it looks like a whole set of "nf_*" subroutines are missing. I would assume these are NetCDF functions. So perhaps the /usr/local/lib/libnetcdf.a is bad. What does 'file /usr/local/lib/libnetcdf.a' command show? Is it 32 bit or 64 bit library? You have to be consistent, if you are using the 64 bit compiler, libnetcdf.a should be "object x86_64". It looks like you are mixing 32 and 64 bit objects which you cannot do.

ron


0 Kudos
changks888
Beginner
3,207 Views
Hi Ron,
(1) It should be64bit Intel Fortran on my Lion OSX Lion.
$ ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100203
(2) To build NetCDF 4.1.3 on Mac OSX Lion, I use the following environment variables:
$ lt_cv_ld_force_load=no FC="ifort" F77="ifort" F90="ifort" CC="cc" CXX=""
$ export CFLAGS='-O3 -m64'
$ export FCFLAGS='-O3 -m64'
$ export FFLAGS='-O3 -m64'
$ ./configure -disable-netcdf-4
$ make
$ make check
$ sudo make install
(3) I check the NetCDF library in /usr/local/libto make sure they were compiled using64bit Intel Fortran. Is the problem cuased by/usr/local/lib/libnetcdf.a ??
$ file libnetcdf.a
libnetcdf.a: current ar archive random library
$ file libnetcdf.dylib
libnetcdf.dylib: Mach-O 64-bit dynamically linked shared library x86_64
(4) For compiling the program with NetCDF libaray, I use the follwing environment variables:
F77 = ifort
F77_OPTIONS = -O2 -132 -m64
INCLUDE_DIRS = -I/usr/local/include
LD_OPTIONS_NETCDF = /usr/local/lib/libnetcdf.a
Then, I check the ies-io.o and io.o to make sure they were compiled correctly (64bit).
$ file ies-io.o
ies-io.o: Mach-O 64-bit object x86_64
$ file io.o
io.o: Mach-O 64-bit object x86_64
(5) I went back to check the NetCDF log file, config.log to make sure if any undefined/missing symbols. There are someundefined symbols listed as below 5.1-5.4 showed
(5.1)
configure:25347: checking if Fortran 90 compiler capitalizes .mod filenames
configure:25354: gfortran conftest.f90 >&5
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found for architecture x86_64
(5.2)
configure:25778: checking for _doprnt
configure:25778: gcc -o conftest -O3 -m64 conftest.c -lcurl >&5
Undefined symbols for architecture x86_64:
"__doprnt", referenced from:
_main in ccE52Hlu.o
ld: symbol(s) not found for architecture x86_64
(5.3)
configure:25889: checking for MPI_Comm_f2c
configure:25889: gcc -o conftest -O3 -m64 conftest.c -lcurl >&5
Undefined symbols for architecture x86_64:
"_MPI_Comm_f2c", referenced from:
_main in ccYdi7iG.o
ld: symbol(s) not found for architecture x86_64
(5.4)
configure:26760: checking for library containing deflate
configure:26791: gcc -o conftest -O3 -m64 conftest.c -lcurl >&5
Undefined symbols for architecture x86_64:
"_deflate", referenced from:
_main in cc7UWNOE.o
ld: symbol(s) not found for architecture x86_64
Ron: What do you think?! Please let me know.
Thanks,
Michael
0 Kudos
changks888
Beginner
3,207 Views
ISSUES SOLVED.
I did notlink the program to the netcdf library (i.e., include and lib files) properly when compiling a fortran program.
For example, in your command line:
$ nc-config --fflags
-O3 -m64-I/usr/local/include
$ nc-config --flibs
-L/usr/local/lib -lnetcdff -lnetcdf
then, theINCLUDE_DIRS andLD_OPTIONS_NETCDF should be pointed to the exact directories.
INCLUDE_DIRS =-I/usr/local/include
LD_OPTIONS_NETCDF =-L/usr/local/lib -lnetcdff -lnetcdf
Thanks Ron.
0 Kudos
Reply