LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-27-2009, 07:48 PM   #1
limh
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Rep: Reputation: 0
Unhappy Error When Performing "make all" : /usr/bin/ld: -f may not be used without -shared


Software: CosmoMC
Today, after I have successfully compiled the camb, the CFITSIO and WMAP_5yr_likelihood_v3(whchi I have ran "make check" to make sure it was properly compiled) , I ran "make all" in the source subdirectory and an error poped out.

Here is my Makefile in the source subdirectory(the green part denotes the step which the error occured):

#You may need to edit the library paths for MKL for Intel
#Beware of using optmizations that lose accuracy - may give errors when running
#Edit for CFITSIO directories
cfitsio = /home/limh/mywork/cfitsio_81
#/usr/local/Cluster-Users/cpac/cmb/2.1.0/cfitsio
WMAP = /home/limh/mywork/WMAP5/likelihood_v3
IFLAG = -I
INCLUDE=
#Intel MPI (assuming mpif77 set to point to ifort)
#change -lmkl_ia32 to -lmkl_p3 for MKL versions earlier than 6 (6 needed for ifc 8+)
F90C = gfortran
FFLAGS = -O2 -ffree-form
LAPACKL = -Wl,-framework -Wl,accelerate

...
PROPOSE = propose.o
CLSFILE = CMB_Cls_simple.o
#Can use params_H if you prefer more generic parameters
PARAMETERIZATION = params_CMB.o
WMAP_inc = $(IFLAG)$(cfitsio)/include $(IFLAG)$(WMAP)
WMAP_lib = -L$(cfitsio)/lib -L$(WMAP) -lcfitsio
CLSLIB = $(WMAP_lib) -L../camb -lcamb $(LAPACKL)
F90FLAGS = -DMATRIX_SINGLE $(FFLAGS) $(WMAP_inc) $(IFLAG)../camb $(INCLUDE)
DISTFILES = utils.o Matrix_utils.o settings.o GetDist.o
WMAPOBJS = $(WMAP)/read_archive_map.o \
$(WMAP)/read_fits.o \
$(WMAP)/WMAP_5yr_options.o \
$(WMAP)/WMAP_5yr_util.o \
$(WMAP)/WMAP_5yr_tt_pixlike.o \
$(WMAP)/WMAP_5yr_likelihood.o \
$(WMAP)/WMAP_5yr_gibbs.o \
$(WMAP)/WMAP_5yr_tt_beam_ptsrc_chisq.o \
$(WMAP)/br_mod_dist.o
OBJFILES= $(WMAPOBJS) utils.o Matrix_utils.o settings.o cmbtypes.o Planck_like.o \
cmbdata.o WeakLen.o mpk.o supernovae.o SDSSLy-a-v3.o\
$(CLSFILE) paramdef.o $(PROPOSE) $(PARAMETERIZATION) calclike.o \
conjgrad_wrapper.o EstCovmat.o postprocess.o MCMC.o driver.o

default: cosmomc
all : cosmomc getdist
settings.o: utils.o
cmbtypes.o: settings.o
Planck_like.o: cmbtypes.o
cmbdata.o: Planck_like.o $(WMAPOBJS)
WeakLen.o: cmbtypes.o
mpk.o: cmbtypes.o
supernovae.o: cmbtypes.o
SDSSLy-a-v3.o: cmbtypes.o
$(CLSFILE): cmbtypes.o
paramdef.o: $(CLSFILE)
$(PROPOSE): paramdef.o
$(PARAMETERIZATION): paramdef.o
calclike.o: $(PARAMETERIZATION)
conjgrad_wrapper.o: calclike.o
EstCovmat.o: conjgrad_wrapper.o
postprocess.o: calclike.o
MCMC.o: calclike.o
driver.o: MCMC.o

.f.o:
f77 $(F90FLAGS) -c $<
%.o: %.f90
$(F90C) $(F90FLAGS) -c $*.f90
%.o: %.F90
$(F90C) $(F90FLAGS) -c $*.F90
cosmomc: $(OBJFILES) ../camb/libcamb.a
$(F90C) -o ../cosmomc $(OBJFILES) $(CLSLIB) $(F90FLAGS)


clean:
rm -f *.o *.mod *.d *.pc *.obj ../core
getdist: $(DISTFILES)
$(F90C) -o ../getdist $(DISTFILES) $(CLSLIB) $(F90FLAGS)
...


The feedback was:
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c utils.F90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c Matrix_utils.F90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c settings.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c cmbtypes.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c Planck_like.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c cmbdata.F90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c WeakLen.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c mpk.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c supernovae.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c SDSSLy-a-v3.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c CMB_Cls_simple.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c paramdef.F90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c propose.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c params_CMB.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/likelihood_v3 -I../camb -c calclike.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c conjgrad_wrapper.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c EstCovmat.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c postprocess.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c MCMC.f90
gfortran -DMATRIX_SINGLE -O2 -ffree-form -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/
likelihood_v3 -I../camb -c driver.F90
gfortran -o ../cosmomc /home/limh/mywork/WMAP5/likelihood_v3/read_archive_map.o /home/limh/mywork/WMAP5/likeli
hood_v3/read_fits.o /home/limh/mywork/WMAP5/likelihood_v3/WMAP_5yr_options.o /home/limh/mywork/WMAP5/likeliho
od_v3/WMAP_5yr_util.o /home/limh/mywork/WMAP5/likelihood_v3/WMAP_5yr_tt_pixlike.o /home/limh/mywork/WMAP5/li
kelihood_v3/WMAP_5yr_teeebb_pixlike.o /home/limh/mywork/WMAP5/likelihood_v3/WMAP_5yr_likelihood.o /home/limh/
mywork/WMAP5/likelihood_v3/WMAP_5yr_gibbs.o /home/limh/mywork/WMAP5/likelihood_v3/WMAP_5yr_tt_beam_ptsrc_ch
isq.o /home/limh/mywork/WMAP5/likelihood_v3/br_mod_dist.o utils.o Matrix_utils.o settings.o cmbtypes.o Planck_lik
e.o cmbdata.o WeakLen.o mpk.o supernovae.o SDSSLy-a-v3.o CMB_Cls_simple.o paramdef.o propose.o params_CMB.o calclike.o
conjgrad_wrapper.o EstCovmat.o postprocess.o MCMC.o driver.o -L/home/limh/mywork/cfitsio_81/lib -L/home/limh/mywo
rk/WMAP5/likelihood_v3 -lcfitsio -L../camb -lcamb -Wl,-framework -Wl,accelerate -DMATRIX_SINGLE -O2 -ffree-fo
rm -I/home/limh/mywork/cfitsio_81/include -I/home/limh/mywork/WMAP5/likelihood_v3 -I../camb

usr/bin/ld: -f may not be used without -shared
collect2: ld returned 1
make: *** [cosmomc] Error 1


I am by no means an expert and don't understand the error message, so could you please help me? Any advice is welcome.
Thanks a lot for your help!
A desperate fish
 
Old 08-27-2009, 09:04 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Flags: FFLAGS = -O2 -ffree-form

Error: usr/bin/ld: -f may not be used without -shared

Man page for gfortran:
Code:
 -ffree-form
 -ffixed-form

      Specify the layout used by the source file.  The free form layout was introduced in Fortran 90.
      Fixed form was traditionally used in older Fortran programs.  When neither option is specified, the
      source form is determined by the file extension.
I'll take a wild stab at the situation here..

The linker is telling you that to use the -f option, as in -ffree-form, that you need to use the -shared option as well. Alternately, you could remove the -ffree-form option from the FFLAGS and eliminate the problem (theoretically).

According to the man page section above, those two options can/will be automatically determined by the linker, based on file extensions. So you should be able to get by without it.

So, if it were me, I would edit the "Flags" line I put at the very top of this post, and change it to ONE of the following:

FFLAGS = -O2

or

FFLAGS = -O2 -ffree-form -shared

and see if it works.

NOTE: I'm not any kind of expert with Fortran, or with GCC/G77/G90 for that matter, but I base my suggestion on experience with similar, pesky errors, when building C/C++ stuff for my system. Therefore, there's no guarantees here that this will work, and if it DOES, there's no guarantees that the end result will be as expected.

Good luck!
Sasha

Last edited by GrapefruiTgirl; 08-27-2009 at 09:06 PM.
 
Old 08-27-2009, 10:42 PM   #3
limh
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Smile It worked, thanks

Editing the FFLAGS as "FFLAGS = -O2" didn't worked

but "FFLAGS = -O2 -ffree-form -shared" did!!

Thanks for your prompt reply! Sincerely! ^-^
 
Old 08-27-2009, 10:54 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Excellent! Glad it's working
Sasha

PS - if it's completely solved, you can mark your thread as [solved] using the "Thread Tools" from the drop down menu at the top of the thread.

Cheers!
Sasha
 
Old 08-28-2009, 02:39 AM   #5
limh
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Question One more question!

Hi ,Sasha~^-^
After I have removed the "-f may not be used without shared" problem,
I stepped into another one:

/usr/bin/ld: accelerate: No such file: No such file or directory
collect2: ld returned 1
make: *** [cosmomc] Error 1

Maybe it is more luminous--that is to say I don't have a file called "accelerate" in the camb subdirectory, but I don't have a "framework" or "ramework" as well! Why didn't the program report that it couldn't find the framework ,but the "accelerate"?
Maybe it was due to the "-" before the "ramework",I think.But I don't know well enough. I don't know what the line "LAPACKL = -Wl,-framework -Wl,accelerate" mean. What is -Wl?

Last edited by limh; 08-28-2009 at 08:18 PM.
 
Old 08-28-2009, 08:21 AM   #6
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
-Wl is a label indicating the beginning of a list of things that the linker should include. The intention is so that the linker doesn't "forget" to include ALL items in the list, when doing its job. For example:

-Wl,hello, goodbye, testing, biggleboggle,-Wl

makes sure that the linker included everything between the -Wl tags.

Code:
From "man ld":

Note---if the linker is being invoked indirectly, via a compiler driver (e.g. gcc) then all the linker
       command line options should be prefixed by -Wl, (or whatever is appropriate for the particular compiler
       driver) like this:

                 gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup

       This is important, because otherwise the compiler driver program may silently drop the linker options,
       resulting in a bad link.
try:

shell# man ld

for the exact syntax & context.

I think you may be right: try removing that leading dash, in front of "framework"

Sasha
 
Old 08-28-2009, 08:39 PM   #7
limh
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Smile

Hi, Sasha
ok,I will try your suggestions!

While waiting for your reply, I had turned to the "Intel® Fortran Compiler User and Reference Guides" for help and find that "-Wl" is one of the options of the compiler,which I didn't find in other Fortran User Guides. so I think it is an unique option of the Intel Fortran compiler. I used the Gfortran compiler,maybe the compiler couldn't recognized the "-Wl" and then came the error.

Solution: I drop this "bizarre" line in the Makefile and go on "make all". It worked!! But with 3 warnings about the syntex "Goto" in the codes. I will go on to see whether the difference of compilers would bring any problem in running the program.

Thank you for your generous and prompt help for a fish! You can contact me via my email. Discussing with you is a great time for me!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error When performing Make: "/usr/bin/ld: cannot find -lpanel" paulmwiu Linux - General 6 08-28-2009 12:28 PM
script using "/usr/bin/cat error" produces "cannot open" in cron Dcrusoe Programming 6 07-22-2009 03:30 PM
LFS6.3 - Ch5.4.1 "/bin/sh sort not found" error at "make bootstrap" ubyt3m3 Linux From Scratch 2 06-23-2008 12:09 AM
problem "make"ing gtk+ "/usr/bin/env: perl -w" caid Linux - Newbie 8 07-29-2005 04:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration