Find the answer to your Linux question:
Page 1 of 6 1 2 3 4 5 ... LastLast
Results 1 to 10 of 52
First of all I want to be honest that I know nothing with either Linux or C/C++ language. I'm a web developer and I'm the only one here. My company ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2014
    Location
    Maryland
    Posts
    24

    Can'r run makefile in Linux using PuTTY, plase help!


    First of all I want to be honest that I know nothing with either Linux or C/C++ language. I'm a web developer and I'm the only one here. My company is a small company with only 5 people.
    While developing my web application, I came up with an md5 executable file that is used for login purpose. This md5 file is used to manage users' login in solaris. But since we're migrating to Linux, the md5 is not working anymore and I was told I need to create a new md5 executable file for Linux from the source files.

    I need help and I hope I submitted this to the right Forum, Thanks.

    I have several files, some ending in .c, .o and .h and one makefile file, here are their names:
    --------------------------------
    basic.h
    md5, md5.c, md5.h, md5.o
    makefile
    md5test.c, md5test.o, md5test.h
    usbreak.c, usbreak,o, usbreak.h
    utils.c, utils.o, utils.h

    Within makefile, you'll see this:
    ----------------------------
    md5: md5test.o md5.o utils.o usrbreak.o
    gcc md5test.o md5.o utils.o usrbreak.o -o md5

    md5test.o: md5test.c
    gcc -c md5test.c

    md5.o: md5.h md5.c
    gcc -c md5.c

    utils.o: usrbreak.h utils.h utils.c
    gcc -c utils.c

    usrbreak.o: usrbreak.h basic.h usrbreak.c
    gcc -c usrbreak.c
    clean:
    rm *.o md5

    -----------------------------------------------------------
    So, after some googling and reading I opened my PuTTy and start typing the following:
    (I'm on my root folder /home/www/mytest/ and those source files are in mytest folder.)
    -----------------------------------------------------------

    # make -f makefile

    and I got this:
    -------------

    gcc md5test.o md5.o utils.o usrbreak.o -o md5
    /usr/bin/ld: md5test.o: Relocations in generic ELF (EM: 2)
    md5test.o: could not read symbols: File in wrong format
    collect2: ld returned 1 exit status
    make: *** [md5] Error 1

    I don't know what this error is and how to interpret them and what should I do next. Please help!!

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,296
    try running "make clean" first. The "-f makefile" isn't neccessary as long as you are in the directory.
    Code:
     
    make clean && make

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,391
    Slightly off-topic:
    The approach seems a bit odd.

    1) The point of hashed passwords is to protect (as in: buy time) the real passwords in case an attacker gains access to the hashes.
    md5 cannot provide the needed resilience, it is broken in that regard.
    MD5 - Wikipedia, the free encyclopedia
    2) Calling an external tool from an webapp is problematic, not only from performance, but also from input validation and data handling point of view.
    e.g. How would you pass an array or even more complex data structures to a cli tool?
    In your case it seems even more odd, as native md5 functions are part of more or less any language. php, perl, ruby, java,..
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    May 2014
    Location
    Maryland
    Posts
    24
    Thank you for responding.
    When I type in" make clean && make, I got:
    -----------------------------------------
    rm *.o md5
    rm: cannot remove `md5': No such file or directory
    make: *** [clean] Error 1

    When I typed: make, I got:
    -------------------------
    gcc -c md5test.c
    In file included from md5test.c:1:
    md5.h:123: error: expected specifier-qualifier-list before ‚uint32_t‚
    md5.h:135: error: expected declaration specifiers or ‚...‚ before ‚uint32_t‚
    md5.h:139: error: expected ‚)‚ before ‚*‚ token
    make: *** [md5test.o] Error 1

    After posting my respond (above), I found out that under my test folder I did not have the file called: md5
    I have md5.c, md5.h, md5.o but no md5, so, I added the md5 file and then run:
    make clean && make and got this:

    rm *.o md5
    rm: cannot remove `*.o': No such file or directory
    make: *** [clean] Error 1

    Question:
    --------
    What is rm*.o md5
    I don't have file called rm
    I added md5 file and the rest of the files that are written inside makefile are in mytest folder
    I don't understand
    Last edited by Alecken; 05-05-2014 at 05:39 PM.

  5. #5
    Just Joined!
    Join Date
    May 2014
    Location
    Maryland
    Posts
    24
    hi Irithori, This is a hand me down webapp. This webapp is actually a supplement app to the real app.
    I guess the idea is so users don't have to remember more passwords when login into the real app and the webapp since both of them are working hand in hand. The real app that was written in VB is a client-server app.

  6. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,391
    That explanation opens even more questions.
    You might be lucky (or not), that I am not your devops/operations guy
    I would probably flat out reject that project, based on the few infomations so far.

    But if you want/must go on:
    You might want to look into replacing that md5 executeable with native functions or -if that also should be to problematic- replace it with the already available md5sum binary provided via a linux package.
    You must always face the curtain with a bow.

  7. #7
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,296
    Quote Originally Posted by Alecken View Post
    Thank you for responding.
    When I type in" make clean && make, I got:
    -----------------------------------------
    rm *.o md5
    rm: cannot remove `md5': No such file or directory
    make: *** [clean] Error 1

    When I typed: make, I got:
    -------------------------
    gcc -c md5test.c
    In file included from md5test.c:1:
    md5.h:123: error: expected specifier-qualifier-list before ‚uint32_t‚
    md5.h:135: error: expected declaration specifiers or ‚...‚ before ‚uint32_t‚
    md5.h:139: error: expected ‚)‚ before ‚*‚ token
    make: *** [md5test.o] Error 1

    After posting my respond (above), I found out that under my test folder I did not have the file called: md5
    I have md5.c, md5.h, md5.o but no md5, so, I added the md5 file and then run:
    make clean && make and got this:

    rm *.o md5
    rm: cannot remove `*.o': No such file or directory
    make: *** [clean] Error 1

    Question:
    --------
    What is rm*.o md5
    I don't have file called rm
    I added md5 file and the rest of the files that are written inside makefile are in mytest folder
    I don't understand
    "rm" is a program - short for remove - provided by the OS. "rm*.o md5" removes the object files and executable that are produced by the compilation.

    From the output of the compiler it would appear you have some foreign (unwanted) characters in your source files. You may be able to remove the offending characters. The compiler has told you where they are found though it seems to me you are in over your head.


    Make clean failing isn't an issue.

  8. #8
    Just Joined!
    Join Date
    May 2014
    Location
    Maryland
    Posts
    24
    I can't find any foreign (unwanted) characters with this source file.Can you help find it out because whenever I try to compile I always get these errors (see below) but in md5.h file everything looks good to me.
    What is the meanng of "‚"???

    md5.h:62: error: expected specifier-qualifier-list before ‚uint32_t‚
    md5.h:68: error: expected declaration specifiers or ‚...‚ before ‚uint32_t‚
    md5.h:70: error: expected ‚)‚ before ‚*‚ token
    make: *** [md5test.o] Error 1

    And here is md5.h:
    -----------------
    #ifndef _md5
    #define _md5
    #include "basic.h"

    #define MD5HASHSIZE 16

    /* Data structure for MD5 (Message-Digest) computation */
    typedef struct {
    uint32_t buf[4]; /* scratch buffer */
    uint32_t i[2]; /* number of _bits_ handled mod 2^64 */
    unsigned char in[64]; /* input buffer */
    } MD5_CTX;

    void MD5Init(MD5_CTX **mdContext, size_t *length);
    void MD5Update(MD5_CTX *mdContext, byte *buf, uint32_t len);
    void MD5Final(MD5_CTX **mdContext, byte digest[MD5HASHSIZE], size_t length);
    void Transform(uint32_t *buf, uint32_t *in);

    #endif

  9. #9
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,296
    They are very likely characters that aren't printing characters in the context that you are reading them. They may have been introduced when you transfered the file or may have meant something on the platform you got the code from. Where did you get the source code? Are you sure it is appropriate for a Linux environment?

    It may be the case that, as Irithori has implied, there is a better solution to using this code. That said, for each file that complains you can try:

    Code:
    mv bad_file.h bad_file.h.bak
    tr -cd '\11\12\15\40-\176' < bad_file.h.bak > bad_file.h
    Note that bad_file.h should be replaced by the name of file you wish to clean and the bad_file.h.bak is an insurance that you can restore the original state. This will remove non-printing characters outside of the range accepted by C.

  10. #10
    Just Joined!
    Join Date
    May 2014
    Location
    Maryland
    Posts
    24
    Before I'm trying your suggestion, I'd like to let you know that I just added to the md5.h this line:
    #include <stdint.h>
    then when I ran make -f makefile, it created md5.o and mdtest.o so it looks like I pass the first error.
    Now, I got a new error:
    gcc -c utils.c
    utils.c:32: error: expected identifier before numeric constant
    utils.c: In function ‚blockOK‚:
    utils.c:384: warning: cast from pointer to integer of different size
    utils.c: In function ‚qmalloc‚:
    utils.c:476: warning: cast from pointer to integer of different size
    utils.c: In function ‚qrealloc‚:
    utils.c:568: warning: cast from pointer to integer of different size
    make: *** [utils.o] Error 1

    This is pointing to this codes:
    ---------------------------
    #include "utils.h"
    #include "usrbreak.h"
    #include <string.h>
    /*#define MEMCHECK*/
    /*#define MEMCHAIN*/
    #ifdef MEMCHECK
    #define MEMCHAIN
    #endif

    typedef enum { UNKNOWN, BIG_ENDIAN, LITTLE_ENDIAN } endian_type;

    typedef struct memblock_T
    {
    uint32_t checkword;
    #ifdef MEMCHAIN
    struct memblock_T * next;
    struct memblock_T * prev;
    #endif
    uint32_t marked;
    uint32_t size;
    uint32_t startguard;
    uint32_t data[1];
    } memblock;

    #ifdef MEMCHAIN
    static memblock block0 = { 0, &block0, &block0 };
    #endif

Page 1 of 6 1 2 3 4 5 ... 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
  •