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_