Re: Visual Studio linker problem (strtoll)

Roland Hughes via Foxgui-users <[email protected]>
Newsgroups gmane.comp.lib.fox-toolkit.user
Message-ID <[email protected]>
Hello Enno,

I haven't been using FOX for anything, but stay on the list. This isn't 
a FOX specific problem. I'm older than dirt. I started out with the 
Zortech C++ compiler under MS DOS using floppies.

The short answer is that strtoll() got added to the language standard 
"along the way."

https://en.cppreference.com/w/cpp/string/basic_string/stol

Until compilers supported C++11 (which wasn't in 2011) developers who 
needed to convert strings to long long had to roll their own. Most were 
somewhat polite enough to prefix their stoll with MyPackageStoll() to 
avoid any potential name conflicts. Many also had a macro or three to 
change the name of the function to what would become the standard name 
during those unfortunate years where only "some" compilers had the full 
C++11 standard implemented.

That's the why. FOX has a Windows 95 look and feel because it has been 
around a very long time. That's also why it can run on so many 
platforms. As a UI library it doesn't swing for the fences.

I haven't looked into the build documentation but there should be a 
compiler/make/whatever switch/define that you pass to your build to tell 
it not to use the FOX stoll() because the compiler provides one. You 
probably have to rebuild your FOX library with said switch to get rid of 
your problem. Probably also have to define same thing when building your 
own project.

Roland

On 11/13/22 11:49, Enno Rehling 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?
>
>
> _______________________________________________
> Foxgui-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/foxgui-users

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593

http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog



_______________________________________________
Foxgui-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/foxgui-users
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.