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
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 coming from my other file LDAP.C which contain the load_values_from_attr() function
/****/
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 compiles and can be executed but segfault on it (which is another story).
I can't figure out why the linker is behaving this way.