• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ OS X Mojave Compiling - error: no matching conversion for functional-style cast from

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,249
Solutions
71
Reaction score
621
Location
Hell
@Znote

Started compiling but then this error poped up. Not sure how to fix this .

Code:
[  1%] Generating CXX prefix source cotire/tfs_CXX_prefix.cxx
[  2%] Generating CXX prefix header cotire/tfs_CXX_prefix.hxx
[  3%] Building CXX precompiled header cotire/tfs_CXX_prefix.hxx.pch
Scanning dependencies of target tfs
[  5%] Building CXX object CMakeFiles/tfs.dir/src/otpch.cpp.o
[  6%] Building CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
[  7%] Building CXX object CMakeFiles/tfs.dir/src/ban.cpp.o
[  8%] Building CXX object CMakeFiles/tfs.dir/src/baseevents.cpp.o
[ 10%] Building CXX object CMakeFiles/tfs.dir/src/bed.cpp.o
[ 11%] Building CXX object CMakeFiles/tfs.dir/src/chat.cpp.o
[ 12%] Building CXX object CMakeFiles/tfs.dir/src/combat.cpp.o
[ 13%] Building CXX object CMakeFiles/tfs.dir/src/commands.cpp.o
[ 15%] Building CXX object CMakeFiles/tfs.dir/src/condition.cpp.o
[ 16%] Building CXX object CMakeFiles/tfs.dir/src/configmanager.cpp.o
[ 17%] Building CXX object CMakeFiles/tfs.dir/src/connection.cpp.o
/Users/nedimkanat/Downloads/tfs12/src/connection.cpp:119:30: error: no matching conversion for functional-style cast from 'Connection::(anonymous enum at
      /Users/nedimkanat/Downloads/tfs12/src/connection.h:67:3)' to 'boost::posix_time::seconds'
                readTimer.expires_from_now(boost::posix_time::seconds(Connection::read_timeout));
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from
      'Connection::(anonymous enum at /Users/nedimkanat/Downloads/tfs12/src/connection.h:67:3)' to 'const boost::posix_time::seconds' for 1st argument
  class BOOST_SYMBOL_VISIBLE seconds : public time_duration
                             ^
/usr/local/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: note: candidate constructor (the implicit move constructor) not viable: no known conversion from
      'Connection::(anonymous enum at /Users/nedimkanat/Downloads/tfs12/src/connection.h:67:3)' to 'boost::posix_time::seconds' for 1st argument
/usr/local/include/boost/date_time/posix_time/posix_time_duration.hpp:58:37: note: candidate template ignored: disabled by 'enable_if' [with T = Connection::(anonymous enum at
      /Users/nedimkanat/Downloads/tfs12/src/connection.h:67:3)]
          typename boost::enable_if<boost::is_integral<T>, void>::type* = 0) :
                                    ^
/Users/nedimkanat/Downloads/tfs12/src/connection.cpp:163:30: error: no matching conversion for functional-style cast from 'Connection::(anonymous enum at
      /Users/nedimkanat/Downloads/tfs12/src/connection.h:67:3)' to 'boost::posix_time::seconds'
                readTimer.expires_from_now(boost::posix_time::seconds(Connection::read_timeout));
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
You can try to declare the variable before passing it into the function in the sources, or try to switch to a compatible version of boost, etc 1.65:
Code:
brew switch boost 1.65.0_1
or perhaps?
brew switch boost 1_65_1
(At least ubuntu 18.04 compiles without problem at this version).

Don't remember the proper way to switch between versions. Something along those lines. :p
Perhaps its sufficient to just go down to 67 (Found this while googling).
Code:
brew switch boost 1.67.0_1
 
Last edited:
You can try to declare the variable before passing it into the function in the sources, or try to switch to a compatible version of boost, etc 1.65:
Code:
brew switch boost 1.65.0_1
or perhaps?
brew switch boost 1_65_1
(At least ubuntu 18.04 compiles without problem at this version).

Don't remember the proper way to switch between versions. Something along those lines. :p
Perhaps its sufficient to just go down to 67 (Found this while googling).
Code:
brew switch boost 1.67.0_1

I tried installing 1.67 and 1.65 using boost but they don't seem to exist : boost (https://formulae.brew.sh/formula/boost)

then I tried installing 1.60 :
Code:
brew install [email protected]
installation finished. But when I tried switching to 1.60 I got the following error msg telling me that there's only 1.68 installed -.-
Code:
brew switch boost 1.60
Error: boost does not have a version "1.60" in the Cellar.
boost installed versions: 1.68.0_1

Then I tried executing : brew list and got :
(look at the first column - 1.59, 1.60 and 1.68 installed)
Code:
$ brew list
ant            gdbm            libbluray        [email protected]            pcre            speex
aom            gettext            libevent        luajit            pcre2            sqlite
apr            giflib            libffi            lz4            perl            subversion
apr-util        git            libgpg-error        mpfr            physfs            swig
autoconf        glew            libidn2            mysql            pixman            tbb
automake        glib            libksba            mysql++            pkg-config        tesseract
bison            gmp            libmodplug        mysql-client        pngcrush        theora
boost            gnutls            libmpc            mysql-connector-c    pugixml            unbound
[email protected]        go            libogg            nettle            python            unrar
[email protected]        gobject-introspection    libpng            nmap            python3            utf8proc
cairo            gource            libsamplerate        node            python@2        webp
cmake            graphite2        libsndfile        numpy            readline        wget
coreutils        gstreamer        libsoxr            openblas        rtmpdump        wxmac
cryptopp        harfbuzz        libtasn1        opencore-amr        rubberband        x264
eigen            icu4c            libtiff            opencv            scons            x265
ffmpeg            ilmbase            libtool            openexr            sdl            xml2
flac            isl            libunistring        openjpeg        sdl2            xvid
fontconfig        jpeg            libvorbis        openssl            sdl2_image        xz
freetype        lame            libvpx            [email protected]        sdl2_mixer
frei0r            leptonica        libxml2            opus            sdl2_ttf
fribidi            libarchive        libyaml            p11-kit            smpeg
gcc            libass            little-cms2        p7zip            snappy


UPDATE:

I looked into those folders and found that they were not installed where they should have been in order for switch to work so I moved
those folders into main boost path:
34960

and tried switching again, it worked.. BUT this time after executing "make" in Tfs build folder
i got the following error -.- :
Code:
make[2]: *** No rule to make target `/usr/local/include/boost/asio/associated_allocator.hpp', needed by `cotire/tfs_CXX_prefix.hxx.pch'.  Stop.
 
Last edited:
After switching the boost version, did you rebuild the makefile? You might be trying to compile boost 1.68 stuff with boost 1.60 now. :p
wipe the build folder and do the cmake command again, I think.
 
After switching the boost version, did you rebuild the makefile? You might be trying to compile boost 1.68 stuff with boost 1.60 now. :p
wipe the build folder and do the cmake command again, I think.

I've tried that but no luck.

Also I compiled boost 1.67 following these steps. And then ofc switched to 1.67 using brew.
removed build folder, remade it and executed cmake .. command. But no luck. same error:
Code:
connection.cpp:257:31: error: no matching conversion for functional-style cast from 'Connection::(anonymous enum at
      /Users/nedimkanat/Downloads/tfs12/src/connection.h:66:3)' to 'boost::posix_time::seconds'
 
Last edited:
Does compiling the master commit work?
-> if not, create an issue
-> if it gets solved, apply the patch to your TFS 1.2 source
-> If it works on master and not on your 1.2 source, look at the diff.
 
Does compiling the master commit work?
-> if not, create an issue
-> if it gets solved, apply the patch to your TFS 1.2 source
-> If it works on master and not on your 1.2 source, look at the diff.

Ok I have downloaded the master branch and started compiling.
First I got some error whining about some mysql header not being found.
I installed mysql using brew install mysql (unlinked mysql-connector-c)

Then I got : mysql file not found with <angled>include; use "quotes" instead
I opened the mysql header file and used quotes instead.

Its not compiling and is at 63%. So far no more errors.



UPDATE:
@Znote

master-branch worked.

is this the right way to compare the branches ?
 
Last edited:
Yes, assuming your TFS 1.2 source is not modified.
Why are you using TFS 1.2? Is it vanilla 1.2 (this) or with modifications?

I cant think of a good reason to use 1.2, unless there are custom source modifications, etc to support client 8.6. In which case a compare such as that one might not be sufficient.

If its clean 1.2 I would recommend you to go 1.3 instead, there have been several bugfixes over the past 2.5 years.
If the source is modified, I would look at the compile errors you have in 1.2, etc:
Code:
connection.cpp:257:31: error: no matching conversion for functional-style cast from 'Connection::(anonymous enum at
      /Users/nedimkanat/Downloads/tfs12/src/connection.h:66:3)' to 'boost::posix_time::seconds'

Look in connection.cpp:257, which function is this? How does this function look in TFS 1.3? How does this function look in the original 1.2 sources? Can the code be adapted to work like they do it 1.3 without breaking?
 
Last edited:
The problem is that the compiler is trying to match, and cast, the enum argument (Connection::read_timeout) to the parameter type boost::posix_time::seconds, but that's not possible. However, the method does accept a long value as an argument, and Connection::read_timeout is an integral value, so you could just cast it to a long:
C++:
readTimer.expires_from_now(boost::posix_time::seconds(static_cast<long>(Connection::read_timeout)));
Or, you can do as Mark did in this commit: Fix build error · otland/forgottenserver@7193a67 (https://github.com/otland/forgottenserver/commit/7193a670c6b5b7cff472e1946e5b1e7ca7e1051b)
 
Why are you using TFS 1.2? Is it vanilla 1.2 (this) or with modifications?

I cant think of a good reason to use 1.2, unless there are custom source modifications, etc to support client 8.6. In which case a compare such as that one might not be sufficient.

If its clean 1.2 I would recommend you to go 1.3 instead, there have been several bugfixes over the past 2.5 years.
If the source is modified, I would look at the compile errors you have in 1.2, etc:
Code:
connection.cpp:257:31: error: no matching conversion for functional-style cast from 'Connection::(anonymous enum at
      /Users/nedimkanat/Downloads/tfs12/src/connection.h:66:3)' to 'boost::posix_time::seconds'

Look in connection.cpp:257, which function is this? How does this function look in TFS 1.3? How does this function look in the original 1.2 sources? Can the code be adapted to work like they do it 1.3 without breaking?

Well the idea was to compile a newer tfs which supported 10.00 and work on the server from there on. :D I am not sure what master branch has as version (possible to switch to 10.00 without breaking stuff ?).
 
The master branch is 10.98, same as TFS 1.2. The protocol hasn't changed since last release.
 
Solution
Back
Top