This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: need help on gfortran and C++
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Mojtaba Seifi <mojtaba dot seifi at gmail dot com>
- Cc: fortran at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Date: Wed, 11 Jan 2012 08:57:10 +0000
- Subject: Re: need help on gfortran and C++
- References: <4F0D3B42.6040100@gmail.com>
On 11 January 2012 07:33, Mojtaba Seifi wrote:
> Dear Sir/Madam,
>
> I'm trying to compile a simple fortran code using gfortran and then using
> this library in a C++ code (compiling by g++). The simple codes for fortran
> and C++ are attached. I use the following commands in terminal (ubuntu) for
> this purpose:
>
> gfortran -c FSub.f90
> ar -rcs libFsub.a FSub.o
> g++ -c main.cpp
> g++ -o main.exe main.o -L/`pwd` -lFsub
>
>
> But I get the following error:
> --------------
> main.o: In function `main':
> main.cpp:(.text+0x41): undefined reference to `MULTAB_'
> collect2: ld returned 1 exit status
> --------------
> I couldn't find any solution on the Internet for this issue.
> Would you please help me on this. I'm new in linux and have no idea how to
> fix this.
Although Tobias and Paul have given you the best ways to solve your
problem, I just want to point out you could have run 'nm' to see the
symbol in the FSub.o object:
$ gfortran -c FSub.f90
$ nm FSub.o
0000000000000000 T multab_
That would have shown you the symbol was called multab_ not MULTAB_