argtable/argtable3

Issue Linking static lib in Windows

Closed this issue · 3 comments

It doesn't matter if I am building for Win32 or 64, when I link against the static lib I am seeing the following errors and warnings and was just curious if this is a know issue or not.

14:10:45 64>argtable3.lib(arg_end.obj) : warning LNK4217: locally defined symbol _fputs imported in function _arg_print_errors
14:10:45 64>argtable3.lib(argtable3.obj) : warning LNK4049: locally defined symbol _fputs imported
14:10:45 64>argtable3.lib(argtable3.obj) : warning LNK4217: locally defined symbol _isspace imported in function _arg_print_formatted_ds
14:10:45 64>argtable3.lib(argtable3.obj) : warning LNK4217: locally defined symbol _strchr imported in function _alloc_longoptions
14:10:45 64>argtable3.lib(getopt_long.obj) : warning LNK4049: locally defined symbol _strchr imported
14:10:45 64>argtable3.lib(argtable3.obj) : warning LNK4217: locally defined symbol _strcspn imported in function _arg_cat_option
14:10:45 64>argtable3.lib(arg_dstr.obj) : warning LNK4217: locally defined symbol ___stdio_common_vsprintf imported in function _arg_dstr_catf
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol ___acrt_iob_func imported in function _dbg_printf
14:10:45 64>argtable3.lib(getopt_long.obj) : warning LNK4049: locally defined symbol ___acrt_iob_func imported
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol ___stdio_common_vfprintf imported in function _dbg_printf
14:10:45 64>argtable3.lib(getopt_long.obj) : warning LNK4049: locally defined symbol ___stdio_common_vfprintf imported
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _calloc imported in function _xcalloc
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _free imported in function _merge
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _malloc imported in function _merge
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _realloc imported in function _xrealloc
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _exit imported in function _panic
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _abort imported in function _panic
14:10:45 64>argtable3.lib(arg_utils.obj) : warning LNK4217: locally defined symbol _getenv imported in function _panic
14:10:45 64>argtable3.lib(getopt_long.obj) : warning LNK4049: locally defined symbol _getenv imported
14:10:45 64>argtable3.lib(getopt_long.obj) : warning LNK4217: locally defined symbol ___stdio_common_vsnprintf_s imported in function _warnx
14:10:45 64>argtable3.lib(getopt_long.obj) : warning LNK4217: locally defined symbol _strncmp imported in function _parse_long_options
14:10:45 64>argtable3.lib(argtable3.obj) : error LNK2019: unresolved external symbol __imp__strncat_s referenced in function _arg_cat_option

Hi @sbonar , the static library is argtable3_static.lib, not argtable3.lib. Please try to link against argtable3_static.lib and see if you still have the same issue. Thanks.

I understand. I'm renaming it when I move it to my build just because that is what it is expecting.
However I did find the issue after searching the web. I don't know if this is a CMake issue on my end or if it needs to be fixed. The VS properties for compiling a the static library had the runtime Library option set to /MD (or /MDd for Debug) which is the DLL Runtime Library and when I changed it to /MT (or MTd for Debug) which is non-DLL Runtime Library my other project that I am linking argtable3 with compile successfully.
Like I said this could just be a difference between the two projects or it might be something that needs to be changed in the CMake files.

Hi @sbonar, you need to use /MT and /MTd to build the static library, since your application uses /MT and /MTd.