-
February 14th, 2008, 02:54 PM
#1
g++ err: linker input file unused because linking not done
I already have the compiled object files *.o, but when I try to create executable (link object files) it outputs following error with each include, library, and object files and no executable is created.
g++: -lsomelib: linker input file unused because linking not done
g++: file.o: linker input file unused because linking not done
...
Following command is executed from the Makefile:
g++ -g -DLINUX -o $(EXE) $(LIBDIR) *.o
Any idea what might be causing this error? I have include all files and libraries which I used during compiling it which was successfull.
Please help.
Thanks
-
February 14th, 2008, 03:13 PM
#2
Re: g++ err: linker input file unused because linking not done
Either there is something wrong with your binutils (i.e. your linker) or with your Makefile. It would help, if you posted the command that g++ is trying to execute, i.e. what $(EXE) and $(LIBDIR) are expanded to.
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf
Premature optimization is the root of all evil --Donald E. Knuth
Please read Information on posting before posting, especially the info on using [code] tags.
-
February 14th, 2008, 06:56 PM
#3
Re: g++ err: linker input file unused because linking not done
Remember that GNU make is not Unix.
Originally Posted by tutorcgs
g++ -g -DLINUX -o $(EXE) $(LIBDIR) *.o
I do not believe that GNU make understands the wildcard, *.o. I think that you must create a file object list which contains each of the object files and link this list to create the executable file.
I would also recommend placing the object file list befor the -o directive because this is more intuitive.
Sincerely, Chris.
Last edited by dude_1967; February 14th, 2008 at 06:57 PM.
Reason: spelling...
You're gonna go blind staring into that box all day.
-
February 14th, 2008, 07:12 PM
#4
Re: g++ err: linker input file unused because linking not done
I just looked at your question again and realized that you are not using GNU make. Sorry.
The response is still valid. I believe that g++ command line does not understand the wildcard. An explicit file list is needed.
Try to create an explicit file list.
Sincerely, Chris.
You're gonna go blind staring into that box all day.
-
February 15th, 2008, 09:01 AM
#5
Re: g++ err: linker input file unused because linking not done
Thanks everyone for helping!
I am using GNU make and sending the list of each object file. I just used the wildcard here just to generalize what I was doing.
I am able to link the files manually now.
From make file it is some how automatically putting -E flag for g++ which is causing not to link. My Makefile doesn't have the -E flag but I am not sure where it is getting from.
Any ideas how Makefile is getting this -E flag automatically?
Thanks
-
February 15th, 2008, 09:26 AM
#6
Re: g++ err: linker input file unused because linking not done
It links and creates the executable. I was using $(CPP) for link command in my Makefile which wasn't define in Makefile. Now I am using the variable which is define and it resolved the link and g++ -E mystery issue.
I hate copy/paste!
Thanks all for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|