g++ err: linker input file unused because linking not done
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: g++ err: linker input file unused because linking not done

  1. #1
    Join Date
    Feb 2008
    Posts
    3

    Question 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

  2. #2
    Join Date
    Jan 2004
    Location
    Düsseldorf, Germany
    Posts
    2,401

    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.

  3. #3
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557

    Re: g++ err: linker input file unused because linking not done

    Remember that GNU make is not Unix.

    Quote 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 05:57 PM. Reason: spelling...
    You're gonna go blind staring into that box all day.

  4. #4
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557

    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.

  5. #5
    Join Date
    Feb 2008
    Posts
    3

    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

  6. #6
    Join Date
    Feb 2008
    Posts
    3

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center