Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
I try to port some code from Windows to Linux, and found some problem when I built it, at first, I wrote a make file for gmake, then I found ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Posts
    19

    linker input file unused because linking not done



    I try to port some code from Windows to Linux, and found some problem when I built it, at first, I wrote a make file for gmake, then I found every time the compiler complaint the same thing,
    "linker input file unused because linking not done", I tried some other sample code, the gcc compiler is fine.
    Please help me out, you may found or solved similar problem before.

    here it is the two files

    ctllines.hpp
    Code:
    /* header file for ctllines */
    int ctllines(void);
    ctllines.cpp

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include "ctllines.hpp"
    
    /**********************************************************************/
    int ctllines&#40;void&#41; &#123;
      int line = 0, status;
    
      // make it a dummy call for testing
      line = line++;
    
      return&#40;line-1&#41;;
    &#125;
    here it is the task I did on RedHat Enterprise WS 3 system.

    [local]$ gcc -c -g CTLLINES.CPP
    gcc: CTLLINES.CPP: linker input file unused because linking not done

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Is this a fatal error? And what does your Makefile look like?

  3. #3
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    Several comments:

    1. it won't link because it cannot find a reference to main()
    Try writing a 'hello world' program and compiling it.

    2. You're compiling C++-looking modukles as if they were C, which means the lstdc++ library will not be invoked by the linker.

    Do you mean to write C code or C++?

  4. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Quote Originally Posted by jim mcnamara
    Several comments:

    1. it won't link because it cannot find a reference to main()
    Try writing a 'hello world' program and compiling it.
    That shouldn't matter, since the command he's using is inhibiting linking (he's using the "-c" switch).

    Quote Originally Posted by jim mcnamara
    2. You're compiling C++-looking modukles as if they were C, which means the lstdc++ library will not be invoked by the linker.
    First of all, I do very much believe that the "gcc" executable will first and foremost look at the file extension to determine which compiler to invoke (remember, "gcc" itself is not a compiler at all, but rather a front-end to the pre-processor, compiler, assembler and linker).

    Second, since he's not linking, libstdc++ wouldn't be linked to begin with.

    That being said, I'm having quite much trouble understanding that error message. It doesn't really look like an error to begin with, but rather some kind of informational message. I don't know what this "linked input file" that it speaks of would refer to, however. I've never seen anything like it.

    Does the compiler generate an object file? As lakerdonald asked, what does that makefile of yours look like?

    An off-topic question: Since your code only contains clean C, why do you name the file ".cpp" as if they would be C++ files? Also, you're not supposed to use ".hpp" for C++ header files. Both C and C++ header files are supposed to be named ".h".

  5. #5
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Quote Originally Posted by Dolda2000
    [Also, you're not supposed to use ".hpp" for C++ header files. Both C and C++ header files are supposed to be named ".h".
    Just as an aside, I believe that this is a common convention that is taught when learning Win32 programming. This is mainly because .h is not a valid extension on Windows, although there are probably other reasons.

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I do believe that ".h" is a valid extension on Windows. While DOS enforced the 8.3 format, 8 and 3 are maximum lengths, not enforced lengths. Both can be NUL-terminated.

    For certain, I was using files with all kinds of extensions (including no extension) while I was using DOS 5.0, like 10 years ago.

  7. #7
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Quote Originally Posted by Dolda2000
    I do believe that ".h" is a valid extension on Windows. While DOS enforced the 8.3 format, 8 and 3 are maximum lengths, not enforced lengths. Both can be NUL-terminated.

    For certain, I was using files with all kinds of extensions (including no extension) while I was using DOS 5.0, like 10 years ago.
    I have actually run into problems on Windows XP before trying to save a header file ( it was called "engine.h" ) and it would spit an error.

  8. #8
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That must have been some broken application. I know for sure that DOS and Windows support both ".c" and ".h", since I've used them myself in some previous projects (using DJGPP -- the DOS port of the GNU toolchain).

  9. #9
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    No, I remember that it was some weird circumstance, I forget why, but Explorer just wouldn't let me. However, the point of the story is that there are many people who are taught to use ".hpp"

  10. #10
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Indeed, but I wonder why anyone would want to teach a non-standard naming convention. Maybe it's just Yet Another Microsoft brokenness...

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •