From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24689 invoked by alias); 5 Feb 2011 11:03:29 -0000 Received: (qmail 24677 invoked by uid 22791); 5 Feb 2011 11:03:27 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,TW_CX,TW_LG,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-bw0-f47.google.com (HELO mail-bw0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 Feb 2011 11:03:19 +0000 Received: by bwz10 with SMTP id 10so3775745bwz.20 for ; Sat, 05 Feb 2011 03:03:16 -0800 (PST) Received: by 10.204.99.77 with SMTP id t13mr12560377bkn.164.1296903796508; Sat, 05 Feb 2011 03:03:16 -0800 (PST) Received: from tom.vanck (e178067112.adsl.alicedsl.de [85.178.67.112]) by mx.google.com with ESMTPS id rc9sm923023bkb.2.2011.02.05.03.03.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Feb 2011 03:03:15 -0800 (PST) Message-ID: <4D4D2E71.9050407@gmail.com> Date: Sat, 05 Feb 2011 12:03:00 -0000 From: Paul van Hoven User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Re: Compilation with g77 works but not with gfortran References: <4D4C3B8D.8010803@gmail.com> <626908448-1296846552-cardhu_decombobulator_blackberry.rim.net-64410111-@bda169.bisx.prod.on.blackberry> <4D4C93AA.2010105@gmail.com> In-Reply-To: <4D4C93AA.2010105@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00115.txt.bz2 Now I got it to work. I found that within the lib directory that contains the gfrotran libs exists another subdirectory called x86_64, i.e. /usr/local/gcc-4.3.5/lib/libgfortran* (32 Bit) and /usr/local/gcc-4.3.5/lib/x86_64/libgfortran* (64 Bit) And instead of linking the program like that... $(MEX) -cxx CXX=$(CXX) CC=$(CXX) FC=$(FCC) LD=$(CXX) -L/usr/local/gcc-4.3.5/lib -lgfortran -lm \ -O -output $@ $^ ... I linked it like that... $(MEX) -cxx CXX=$(CXX) CC=$(CXX) FC=$(FCC) LD=$(CXX) -L/usr/local/gcc-4.3.5/lib/x86_64 -lgfortran -lm \ -O -output $@ $^ Now it works fine. Thanks for your help. Paul van Hoven schrieb: > Thanks for the answers. I replace lg2c with lgfortran. When I try to > compile now I get the following error message > > make clean all > rm -f *.o lbfgsb.mexmaci64 > /usr/local/gcc-4.3.5/bin/gfortran -O3 -x f77-cpp-input -fPIC > -fno-common -m64 -o solver.o -c solver.f > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o matlabexception.o > -c matlabexception.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o matlabscalar.o -c > matlabscalar.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o matlabstring.o -c > matlabstring.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o matlabmatrix.o -c > matlabmatrix.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o arrayofmatrices.o > -c arrayofmatrices.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o program.o -c > program.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o matlabprogram.o -c > matlabprogram.cpp > g++ -O3 -fPIC -fno-common -fexceptions -no-cpp-precomp -arch x86_64 > -m64 -Wall -ansi -DMATLAB_MEXFILE > -I/Applications/MATLAB_R2009b.app/extern/include -o lbfgsb.o -c > lbfgsb.cpp > /Applications/MATLAB_R2009b.app/bin/mex -cxx CXX=g++ CC=g++ FC= LD=g++ > -L/usr/local/gcc-4.3.5/lib -lgfortran -lm \ > -O -output lbfgsb.mexmaci64 solver.o matlabexception.o > matlabscalar.o matlabstring.o matlabmatrix.o arrayofmatrices.o > program.o matlabprogram.o lbfgsb.o > ld: warning: in /usr/local/gcc-4.3.5/lib/libgfortran.dylib, file was > built for i386 which is not the architecture being linked (x86_64) > > > Actually I build the /usr/local/gcc-4.3.5/lib/libgfortran.dylib by > myself some days ago. But somehow the compilation produced a 32 bit > library but I do need a 64 bit library. So I would like to rebuild the > gfortran stuff. But where do I have to configure that > libgfortran.dylib is compiled for a 64 bit system? > > I built the gfortran stuff this way: > In "/Users/toom/Downloads/gcc-4.3.5-base/obj-gcc-4.3.5" I typed the > following commands: > ../gcc-4.3.5/configure --prefix=/usr/local/gcc-4.3.5/ --languages=fortran > make > sudo make install > > and I got a gfortran in /usr/local/gcc-4.3.5 > > So how to I tell the build process that I want a 64 bit compilation? > > tim schrieb: >> Replace lg2c by lgfortran >> Sent via BlackBerry by AT&T >> >> -----Original Message----- >> From: Paul van Hoven >> Sender: gcc-help-owner@gcc.gnu.org >> Date: Fri, 04 Feb 2011 18:46:53 To: >> Subject: Compilation with g77 works but not with gfortran >> >> I have an extension for matlab that i want to compile. The machine on >> which I compile the code has a g77-3.4 and a gfortran-4.2 compiler >> installed. If I set the fortran compiler in the Makefile to g77-3.4 >> the compilation process runs through without any error messages and I >> can use the extension without any problems. >> >> >> Compilation process with g77-3.4: >> toom@gauss:~/Matlab/Mex/lbfgsb-for-matlab> make >> /usr/site-local/bin/g77-3.4 -O3 -fPIC -fexceptions -o solver.o -c >> solver.f >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabexception.o -c matlabexception.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabscalar.o -c matlabscalar.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabstring.o -c matlabstring.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabmatrix.o -c matlabmatrix.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> arrayofmatrices.o -c arrayofmatrices.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> program.o -c program.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabprogram.o -c matlabprogram.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o lbfgsb.o >> -c lbfgsb.cpp >> /net/matlab/Matlab2009b/bin/mex -cxx CXX=/usr/site-local/bin/g++-4.2 >> CC=/usr/site-local/bin/g++-4.2 FC= LD=/usr/site-local/bin/g++-4.2 >> -lg2c -lm \ >> -O -output lbfgsb.mexa64 solver.o matlabexception.o >> matlabscalar.o matlabstring.o matlabmatrix.o arrayofmatrices.o >> program.o matlabprogram.o lbfgsb.o >> toom@gauss:~/Matlab/Mex/lbfgsb-for-matlab> >> >> >> >> But when I replace the g77-3.4 with gfortran-4.2 I get a linker error >> message that looks like this: >> >> >> >> Compilation process with gfortran-4.2: >> toom@gauss:~/Matlab/Mex/lbfgsb-for-matlab> make >> /usr/site-local/bin/gfortran-4.2 -O3 -fPIC -fexceptions -o solver.o >> -c solver.f >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabexception.o -c matlabexception.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabscalar.o -c matlabscalar.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabstring.o -c matlabstring.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabmatrix.o -c matlabmatrix.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> arrayofmatrices.o -c arrayofmatrices.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> program.o -c program.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o >> matlabprogram.o -c matlabprogram.cpp >> /usr/site-local/bin/g++-4.2 -O3 -fPIC -pthread -Wall -ansi >> -DMATLAB_MEXFILE -I/net/matlab/Matlab2009b/extern/include -o lbfgsb.o >> -c lbfgsb.cpp >> /net/matlab/Matlab2009b/bin/mex -cxx CXX=/usr/site-local/bin/g++-4.2 >> CC=/usr/site-local/bin/g++-4.2 FC= LD=/usr/site-local/bin/g++-4.2 >> -lg2c -lm \ >> -O -output lbfgsb.mexa64 solver.o matlabexception.o >> matlabscalar.o matlabstring.o matlabmatrix.o arrayofmatrices.o >> program.o matlabprogram.o lbfgsb.o >> solver.o: In function `timer_': >> solver.f:(.text+0x17c4): undefined reference to `_gfortran_etime' >> solver.o: In function `dcsrch_': >> solver.f:(.text+0x1b66): undefined reference to >> `_gfortran_compare_string' >> solver.f:(.text+0x1ca7): undefined reference to >> `_gfortran_compare_string' >> solver.f:(.text+0x20d8): undefined reference to >> `_gfortran_compare_string' >> solver.f:(.text+0x2215): undefined reference to >> `_gfortran_compare_string' >> solver.o: In function `subsm_': >> solver.f:(.text+0x2cce): undefined reference to `_gfortran_st_write' >> solver.f:(.text+0x2ce2): undefined reference to >> `_gfortran_transfer_character' >> solver.f:(.text+0x2cea): undefined reference to >> `_gfortran_st_write_done' >> ... >> ...long list of errors... >> ... >> solver.f:(.text+0xb31c): undefined reference to `_gfortran_st_write' >> solver.f:(.text+0xb324): undefined reference to >> `_gfortran_st_write_done' >> solver.o: In function `setulb_': >> solver.f:(.text+0xb58c): undefined reference to >> `_gfortran_compare_string' >> collect2: ld returned 1 exit status >> >> mex: link of ' "lbfgsb.mexa64"' failed. >> >> make: *** [lbfgsb.mexa64] Error 1 >> >> >> I'm wondering: Why does this happen? I have another machine on which >> I would also like to compile the code but this machine doesn't have >> g77 installed. >> >