Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

Fortran shared lib .so shows undefined symbol error

csH2
Beginner
3,878 Views

Hi everyone I need help about a compilation issue.

I'm compiling a Fortran code to obtain shared library .so. In the code it uses a module. The compiling has no problem while it reports undefined symbol error when opening the .so library.

Code mesh_map.F are as follows:

 

#include "cfx5ext.h"

    dllexport(mesh_map)
          SUBROUTINE mesh_map (CZ, DZ, IZ, LZ, RZ)
          USE EXTRA_FLUID2
          USE ISO_C_BINDING
          USE IFPORT
          IMPLICIT NONE
          CHARACTER*(1) CZ(*)
          DOUBLE PRECISION DZ(*)
          INTEGER IZ(*)
          LOGICAL LZ(*)
          REAL RZ(*)

          MAP_STATUS = 1

          END

 

extra_fluid2.f90:

 

    Module EXTRA_FLUID2
    INTEGER :: map_status = 0
    end module EXTRA_FLUID2

 

Compiling command:

 

 ifort -c extra_fluid2.f90

/home/xxx/intel/oneapi/compiler/2021.4.0/linux/bin/intel64/ifort -fpic -assume 2underscore -check uninit -warn declarations -diag-error 6717 -ftz -O2 -fp-speculation=safe -fp-model=precise -fp-model=source -fimf-arch-consistency=true -qno-opt-dynamic-align -fpe0 -fomit-frame-pointer -real-size 32 -integer-size 32 -I/usr/ansys_inc/v192/CFX/include -o linux-amd64/ifort/mesh_map.o -c mesh_map.F 
-lrt/xxx/intel/oneapi/compiler/2021.4.0/linux/bin/intel64/ifort -shared -o ./linux-amd64/ifort/libmesh_map.so linux-amd64/ifort/mesh_map.o extra_fluid2.o

 

When I check the .so library using:

 

ldd -r libmesh_map.so

 

The result shows as:

 

undefined symbol: extra_fluid2_mp_map_status__        (./libmesh_map.so)

 

How can I fix this? Thanks in advance.

I've tried compilation in Windows and no problem was found for the dll file. While in Linux it reports above error.

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
3,853 Views

When you compiled  mesh_map.F, you specified -assume 2underscore, but didn't specify that when compiling extra_fluid2.f90. This causes the global symbols to be inconsistent. Take that off.

I'm also puzzled by the "dllexport(meshmap)" in mesh_map.F. I have to assume that's a macro defined in the #include.

View solution in original post

0 Kudos
4 Replies
Steve_Lionel
Honored Contributor III
3,854 Views

When you compiled  mesh_map.F, you specified -assume 2underscore, but didn't specify that when compiling extra_fluid2.f90. This causes the global symbols to be inconsistent. Take that off.

I'm also puzzled by the "dllexport(meshmap)" in mesh_map.F. I have to assume that's a macro defined in the #include.

0 Kudos
csH2
Beginner
3,796 Views

Thank you Steve! Yes, I think dllexport should be removed.

0 Kudos
Barbara_P_Intel
Employee
3,835 Views

dllexport is not required for Linux.  Here's more info.

0 Kudos
csH2
Beginner
3,794 Views
0 Kudos
Reply