Re: Visual Studio linker problem (strtoll)

Jeroen van der Zijp <[email protected]>
Newsgroups gmane.comp.lib.fox-toolkit.user
Organization FOX Toolkit
Message-ID <[email protected]>
On Sun, 13 Nov 2022 18:49:49 +0100
Enno Rehling <[email protected]> wrote:

> I am maintaining a legacy application built with Fox 1.6, and in the 
> course of that work, have stumbled upon a problem when building with 
> Visual Studio 2019 that I've isolated into a small sample. The linker 
> message in question is this:
> 
> Build started...
> 1>------ Build started: Project: strtoll_bug, Configuration: Debug Win32   
> ------
> 1>ucrt.lib(api-ms-win-crt-convert-l1-1-0.dll) : error LNK2005: _strtoll   
> already defined in FOX-1.6.lib(strtoll.obj)
> 1>   Creating library X:\Debug\strtoll_bug.lib and object   
> X:\Debug\strtoll_bug.exp
> 1>X:\Debug\strtoll_bug.exe : fatal error LNK1169: one or more multiply   
> defined symbols found
> 1>Done building project "strtoll_bug.vcxproj" -- FAILED.  
> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
> 
> This is the source (main.cpp):
> 
> #include <cassert>
> #include <cstdlib>
> 
> #include <fx.h>
> #include <FXString.h>
> 
> int main(void)
> {
> 	const char* input = "1234567890test";
> 	char* endp;
> 	long long value = strtoll(input, &endp, 10);
> 	assert(value == 1234567890);
> 	assert(endp[0] == 't');
> 	value = FXLongVal(FXString(input), 10);
> 	assert(value == 1234567890);
> 	return 0;
> }
> 
> It appears that FOX-1.6.lib defines a strtoll function that conflicts 
> with the one in the runtime? Why is that?

The short answer is that some operating systems (or rather, c libraries),
and in particular, Windows did not have a strtoll() version of its own.

Obviously, we're now living in the 64-bit world and current VC++ compilers
and support libraries have implemented this function.

On Linux and FreeBSD we configure the build, and configure would pick up
the presence or absence of strtoll(), and set compile directive -DHAVE_STRTOLL
if it was found, in which case the FOX version wasn't going to be build.

Alas, VC++ project files does still remember the old situation.

My suggestion is to set the -DHAVE_STROLL in the "preprocessor"
sub-panel of your build configuration panel, and then I expect your
problem will go away.



Hope this helps,

		-- JVZ
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.