views:

45

answers:

1

Hi , I m working on windows XP with visual studio 2005. My project is a Cmake project created after creating an LDAP abstraction API on linux.I m trying somehow to make it work on windows.

I've got an unusual linking error of type LNK2019

code :

main.obj : error LNK2019: symbole externe non résolu _strcpy référencé
dans la fonction _menu

it happens that this function is in my main.c and the linking error above is comming from my other file LDAP.C wich contain the load_values_from_attr() function code :

/****/

static INT16 load_values_from_attr(t_LdapSearchContext ctx,
    UINT32 result_max_count, LDAP *ld, LDAPMessage *result_message,
    BerElement *ptr)
{
    UINT16 j=0;
    UINT16 i=0;

    char *str_attr; 
    struct berval **str_values;
    str_attr=ldap_first_attribute(ld, result_message, &ptr);

    if (str_attr == NULL) return 1;
    str_values=ldap_get_values_len(ld, result_message, str_attr);
    strcpy(ctx.attributs[i].attrs, str_attr);
    while(str_values[j]!=NULL && j+1<RESULT_WIDTH)
    {
        strncpy(ctx.attributs[i].values[j+1].val,
            str_values[j]->bv_val,MAX_LENGTH);
#ifdef WIN32
        ber_bvfree(str_values[j]); // <<< here is my problem
#endif
        j++;
    }

/****/

When i delete or comment the line with : ber_bvfree(str_values[j]); the Linking error happen, and when i leave it there , the program compil and can be executed but segfault on it (wich is another story). I can t figure out why the linker is behaving this way , if anyboby can give me some explaination i ll be glade.

don't hesitate to ask me more explainations.

A: 

Finally !! after working on linker option in visual studio , i figure our that there was /NODEFAULTLIB:msvcrtd.lib enable , option that screwed the linker. without it linker can link correctly the different objects. (this option ve been enable after observing there was lnk2001 linker problem in my code as well)

NB: I still can t tell why this option is involved in trouble linking my own object , usualy /NODEFAULTLIB:msvcrtd.lib is used to disable the default library msvcrtd.lib inclusion.

i hope this will help somebody

LELEVATOR