Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++: error: unrecognized option ‘--as-needed’

Tags:

c++

g++

I am using Ubuntu 12.10 with a gcc version 4.6.3. I am trying to build my code and getting an error when using 'make' command

g++: error: unrecognized option ‘--as-needed’

My Makefile looks as follows:

LFLAGS = -Wl,-rpath,. -Wl,-rpath-link,../bin --as-needed
LDFLAGS = $(RPATH) $(RPATHLINK)  -L$(USRLIB) --as-needed

Previously this code was successfully building on RedHat Linux. But now I need to run this code on Ubuntu.

If anyone knows about this. Please help

Regards Gaurav

like image 475
user2793154 Avatar asked Sep 18 '13 20:09

user2793154


2 Answers

@FatalError is right

And also better late than never answering this question.

you need to use -Wl,--as-needed

like image 156
lmedinas Avatar answered Sep 28 '22 18:09

lmedinas


Seems like you had an extra space between the ld specifier "-Wl" and the option to be passed to ls "--as-needed". For the linker to get the extra option from g++ command, it should be "-Wl,--as-needed"

like image 21
SlothQuanta Avatar answered Sep 28 '22 19:09

SlothQuanta