Linking error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kevinkwh
    New Member
    • Feb 2010
    • 13

    Linking error

    HI
    I'm using Berkeley DB and VC ++.
    when i debug my program i got this error.

    error C2664: 'strlen' : cannot convert parameter 1 from 'void *' to 'const char *'

    from this line
    skey->size = (u_int32_t)strl en((skey->data)) + 1;

    so i changed this line
    skey->size = (u_int32_t)strl en((const char *)(skey->data)) + 1;

    it gives me this linking error
    Linking...
    load.obj : error LNK2001: unresolved external symbol "char * optarg" (?optarg@@3PADA )
    load.obj : error LNK2019: unresolved external symbol "int __cdecl getopt(int,char * const *,char const *)" (?getopt@@YAHHP BQADPBD@Z) referenced in function _main


    any ideas please,
    please explain me with simple examples because I'm newbie !!!


    Thanks
    Kevin
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    getopt is not a standard C library function but rather part of POSIX.

    Presumably you are trying to port a program from Unix/Linux/BSD to Windows.

    *nix implements POSIX and supports getopt, as well as all the C standard library. Windows does not fully support POSIX but does implement the C standard library, plus its own system libraries.

    getopt parses the command line so you will need to write your own command line parsing code.

    Comment

    • kevinkwh
      New Member
      • Feb 2010
      • 13

      #3
      Thank for you reply.
      I'll try to write my own.
      :D

      Comment

      Working...