argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
377 stars 65 forks source link

Issue Linking static lib in Windows #51

Closed sbonar closed 4 years ago

sbonar commented 4 years ago

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(argutils.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(getoptlong.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(getoptlong.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 impstrncat_s referenced in function _arg_cat_option

tomghuang commented 4 years ago

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.

sbonar commented 4 years ago

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.

tomghuang commented 4 years ago

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