Question : Problems when using static lib - MS VC++

Hi,

I created a static library from a c program and am trying to use it in another c program in MS VC++.

Now I'm getting a whole bunch of link warnings and errors...

Thanks for your help.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
wpa_supplicant.lib(eap_mschapv2.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_tls.obj) : warning LNK4217: locally defined symbol _free imported in function _eap_tls_process
wpa_supplicant.lib(tncc.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_tls_common.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_leap.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_gtc.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_ttls.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_peap.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(pcsc_funcs.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(crypto_openssl.obj) : warning LNK4217: locally defined symbol _free imported in function _fips186_2_prf
wpa_supplicant.lib(eap_tnc.obj) : warning LNK4217: locally defined symbol _free imported in function _eap_tnc_process
wpa_supplicant.lib(eap.obj) : warning LNK4217: locally defined symbol _free imported in function _eap_sm_set_scard_pin
wpa_supplicant.lib(eap_methods.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(wpabuf.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4049: locally defined symbol _free imported
wpa_supplicant.lib(eap_tls_common.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(base64.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(eap_peap.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(eap_mschapv2.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(eap_tls.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(tncc.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(os_win32.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(crypto_openssl.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(eap_leap.obj) : warning LNK4217: locally defined symbol _malloc imported in function _eap_leap_process_request
wpa_supplicant.lib(eap_ttls.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(eap.obj) : warning LNK4217: locally defined symbol _malloc imported in function _eap_sm_imsi_identity
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(pcsc_funcs.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4049: locally defined symbol _malloc imported
wpa_supplicant.lib(eap.obj) : warning LNK4217: locally defined symbol _isprint imported in function _eap_sm_processNotify
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4049: locally defined symbol _isprint imported
wpa_supplicant.lib(tncc.obj) : warning LNK4049: locally defined symbol __strdup imported
wpa_supplicant.lib(eap_tls_common.obj) : warning LNK4049: locally defined symbol __strdup imported
wpa_supplicant.lib(eap_methods.obj) : warning LNK4217: locally defined symbol __strdup imported in function _eap_get_names_as_string_array
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4049: locally defined symbol __strdup imported
wpa_supplicant.lib(os_win32.obj) : warning LNK4049: locally defined symbol __strdup imported
wpa_supplicant.lib(common.obj) : warning LNK4217: locally defined symbol __strdup imported in function _wpa_get_ntp_timestamp
wpa_supplicant.lib(wpabuf.obj) : warning LNK4217: locally defined symbol _abort imported in function _wpabuf_overflow
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4217: locally defined symbol _printf imported in function _wpa_debug_print_timestamp
wpa_supplicant.lib(os_win32.obj) : warning LNK4049: locally defined symbol _printf imported
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4217: locally defined symbol _vprintf imported in function _wpa_printf
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4217: locally defined symbol _fopen imported in function _wpa_debug_open_file
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4049: locally defined symbol _fopen imported
wpa_supplicant.lib(os_win32.obj) : warning LNK4049: locally defined symbol _fopen imported
wpa_supplicant.lib(wpa_debug.obj) : warning LNK4217: locally defined symbol _fclose imported in function _wpa_debug_close_file
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4049: locally defined symbol _fclose imported
wpa_supplicant.lib(os_win32.obj) : warning LNK4049: locally defined symbol _fclose imported
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4217: locally defined symbol _strchr imported in function _tls_match_altsubject
wpa_supplicant.lib(eap_mschapv2.obj) : warning LNK4217: locally defined symbol _strchr imported in function _eap_mschapv2_failure_txt
wpa_supplicant.lib(common.obj) : warning LNK4049: locally defined symbol _strchr imported
wpa_supplicant.lib(eap_tls_common.obj) : warning LNK4049: locally defined symbol _strchr imported
wpa_supplicant.lib(tls_openssl.obj) : warning LNK4217: locally defined symbol _strncmp imported in function _tls_match_altsubject
wpa_supplicant.lib(eap_mschapv2.obj) : warning LNK4217: locally defined symbol _strncmp imported in function _eap_mschapv2_failure_txt
wpa_supplicant.lib(eap_tls_common.obj) : warning LNK4049: locally defined symbol _strncmp imported
wpa_supplicant.lib(os_win32.obj) : warning LNK4217: locally defined symbol _fread imported in function _os_readfile
wpa_supplicant.lib(os_win32.obj) : warning LNK4217: locally defined symbol _ftell imported in function _os_readfile
wpa_supplicant.lib(os_win32.obj) : warning LNK4217: locally defined symbol _fseek imported in function _os_readfile
wpa_supplicant.lib(eap_peap.obj) : warning LNK4217: locally defined symbol _atoi imported in function _eap_peap_parse_phase1
wpa_supplicant.lib(eap_mschapv2.obj) : warning LNK4049: locally defined symbol _atoi imported
wpa_supplicant.lib(tncc.obj) : warning LNK4049: locally defined symbol _atoi imported
wpa_supplicant.lib(tncc.obj) : warning LNK4217: locally defined symbol _strtoul imported in function _tncc_get_type
wpa_supplicant.lib(eap_peap.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(common.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(tncc.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(eap_tls_common.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(eap.obj) : error LNK2019: unresolved external symbol __imp___snprintf referenced in function _eap_sm_get_status
wpa_supplicant.lib(eap_methods.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(tls_openssl.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(eap_ttls.obj) : error LNK2001: unresolved external symbol __imp___snprintf
wpa_supplicant.lib(tncc.obj) : error LNK2001: unresolved external symbol __imp__strstr
wpa_supplicant.lib(eap_tls_common.obj) : error LNK2001: unresolved external symbol __imp__strstr
wpa_supplicant.lib(eap.obj) : error LNK2019: unresolved external symbol __imp__strstr referenced in function _eap_is_wps_pbc_enrollee
wpa_supplicant.lib(tls_openssl.obj) : error LNK2001: unresolved external symbol __imp__strstr
wpa_supplicant.lib(eap_ttls.obj) : error LNK2001: unresolved external symbol __imp__strstr
wpa_supplicant.lib(eap_peap.obj) : error LNK2001: unresolved external symbol __imp__strstr
wpa_supplicant.lib(wpabuf.obj) : error LNK2019: unresolved external symbol __imp__realloc referenced in function _wpabuf_resize
wpa_supplicant.lib(eap_ttls.obj) : error LNK2001: unresolved external symbol __imp__realloc
wpa_supplicant.lib(eap_tls_common.obj) : error LNK2001: unresolved external symbol __imp__realloc
wpa_supplicant.lib(wpabuf.obj) : error LNK2019: unresolved external symbol __imp___vsnprintf referenced in function _wpabuf_printf
wpa_supplicant.lib(wpa_debug.obj) : error LNK2001: unresolved external symbol __imp___vsnprintf
wpa_supplicant.lib(wpa_debug.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _wpa_debug_print_timestamp
wpa_supplicant.lib(wpa_debug.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function _wpa_printf
wpa_supplicant.lib(os_win32.obj) : error LNK2019: unresolved external symbol __imp___gmtime64 referenced in function _gmtime
wpa_supplicant.lib(os_win32.obj) : error LNK2019: unresolved external symbol __imp___localtime64 referenced in function _localtime
wpa_supplicant.lib(os_win32.obj) : error LNK2019: unresolved external symbol __imp___mktime64 referenced in function _mktime
wpa_supplicant.lib(os_win32.obj) : error LNK2019: unresolved external symbol __imp__rand referenced in function _os_random
wpa_supplicant.lib(os_win32.obj) : error LNK2019: unresolved external symbol __imp__calloc referenced in function _os_zalloc

Answer : Problems when using static lib - MS VC++

First, check in the project properties -> Linker -> input  that Ignore all default libraries is not set to Yes.

Second, It is to do the way you are linking with MFCs.
In the projet properties -> Configuration properties -> General -> Use of MFC  set Use MFCs in a static library.

Good luck.
Random Solutions  
 
programming4us programming4us