toddw123 / RotMG_Clientless

Compatible with version X16.0.0
MIT License
11 stars 4 forks source link

Linux support :D #45

Closed VoOoLoX closed 7 years ago

VoOoLoX commented 7 years ago

Mini tutorial on how to compile it

Requirements: CMake, Make, compiler, and libraries that go with the project

BTW I fixed the moving it work perfectly now (it was a timing problem)

Zeroeh commented 7 years ago

Hell yeah, gonna get this working on my mac. Are you using g++ to compile?

toddw123 commented 7 years ago

So guess you cant put a pull request into a new branch. swear i saw something like that before. Oh well.

Anyways, i created a new branch "linux" and pulled your changes to it. So im going to close this pull request. If i messed up somewhere just say something

toddw123 commented 7 years ago

Hmm im re-opening this pull request so we can continue talking about it here.

I tested on my VM and it still doesnt work, but thats probably a problem on my end. I had to change the cmake required version to 3.5 because i dont have 3.7 for some reason. Also had to add the lines that i got from my old cmake file i tried creating a few weeks ago:

include_directories(~/Documents/Projects/openssl/include)
include_directories(~/Documents/Projects/curl/include)

Once i did both of those things the cmake worked. But then i get the same errors i was getting before when i attempted to get it compiling: errors

So i guess my first question is how you set up the libraries for linux? I believe i have them set up correctly, but however you set them up clearly doesnt require you to specify their path in your cmake file.

VoOoLoX commented 7 years ago

@Zeroeh It should work with both GCC and G++ (because G++ is part of GCC and CMake should do everything for you) @toddw123 I didn't have to do anything with libraries. I used system included ones which came with my distro (Arch Linux (Apricity OS to be exact, but it's based on Arch)). If you are using Ubuntu the chance is you don't have curl installed just install curl and it should pull libcurl with it (apt install curl), I'm pretty sure openssl comes pre-installed with every distro so that should not be the problem.

You can check to see if libcurl is on your system with ldconfig -p | grep libcurl

toddw123 commented 7 years ago

curl and openssl werent on my system, as far as i could tell. But thats why i installed curl from their site the way they recommended. But ill give the apt-get a shot, even though im pretty sure ive done that already.

And yes i am on branch of ubuntu. Its Xubuntu. Pretty much identical, just some minor differences.

edit: yeah just did sudo apt-get install curl and it tells me i already have the latest version installed.

Although i did do sudo apt-get install openssl and it turns out i apparently didnt have it installed. Once i did that i removed those include_directories lines from the cmake file and it successfully did the cmake ., but doing make after that still gave me the same exact errors.

I might try updating my cmake to the 3.7 version since your make file originally had that as the minimum.

edit 2: looks like i have to manually install cmake 3.7. When i do an apt-get cmake it tells me i already have the latest version (3.5.1). Nuts.

Maybe ill just download Arch Linux and make another vm for this. That might be quicker then this bullshit lol.

VoOoLoX commented 7 years ago

What version of compiler do you have (check it with gcc --verion or g++ --version)? Also try to add set(CMAKE_CXX_STANDARD 11) and set(CMAKE_CXX_STANDARD_REQUIRED ON) to CMake file since in first error it complains about C++ standard.

toddw123 commented 7 years ago

NICE! Thanks for that @VoOoLoX ! I was trying to figure out how to add the compiler option to the cmake file or to make file it generates.

Once i added those 2 lines i got much much further then before. It failed on memset and memcpy in the TileMap.h/micropather code.

Looks like theres some other errors, but ill try to deal with them one at a time and see if i can get it working. Seems im on the right path now.

edit: yeah now im getting to the shit i saw before when i attempted to make it compile on linux. Something related to the unordered_map of functions for the packet handlers:

In file included from /usr/include/c++/5/bits/hashtable.h:35:0, from /usr/include/c++/5/unordered_map:47, from /home/todd/Documents/Projects/RotMG_Clientless/src/Client.h:7, from /home/todd/Documents/Projects/RotMG_Clientless/src/clientless.h:20, from /home/todd/Documents/Projects/RotMG_Clientless/src/clientless.cpp:1: /usr/include/c++/5/bits/hashtable_policy.h: In instantiation of ‘struct std::__detail::__is_noexcept_hash<tagPacketType, std::hash<tagPacketType> >’: /usr/include/c++/5/type_traits:137:12: required from ‘struct std::__and_<std::__is_fast_hash<std::hash<tagPacketType> >, std::__detail::__is_noexcept_hash<tagPacketType, std::hash<tagPacketType> > >’ /usr/include/c++/5/type_traits:148:38: required from ‘struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<tagPacketType> >, std::__detail::__is_noexcept_hash<tagPacketType, std::hash<tagPacketType> > > >’ /usr/include/c++/5/bits/unordered_map.h:100:66: required from ‘class std::unordered_map<tagPacketType, std::function<void(Packet)> >’ /home/todd/Documents/Projects/RotMG_Clientless/src/Client.h:81:62: required from here /usr/include/c++/5/bits/hashtable_policy.h:85:34: error: no match for call to ‘(const std::hash<tagPacketType>) (const tagPacketType&)’ noexcept(declval<const _Hash&>()(declval<const _Key&>()))>

VoOoLoX commented 7 years ago

Seems like that might be caused by older version of compiler.Apparently first error occurs on GCC versions < 4.8.2. I'm using version 6.3.1 20170306

Also make sure you have libstdc++

toddw123 commented 7 years ago

Looks like i have 5.4 or something:

todd@todd-VirtualBox:~/Documents/Projects/RotMG_Clientless$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

todd@todd-VirtualBox:~/Documents/Projects/RotMG_Clientless$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

I see if i can update it though.

toddw123 commented 7 years ago

hmm weird. when i do apt-get install gcc, it tells me there that i have the latest version gcc is already the newest version (4:5.3.1-1ubuntu1).. Which that is different then the version number i get when i do gcc --version. Interesting. I find it strange that both gcc --version and g++ --version produced the same output + version when i did that. Maybe g++ is being used even when i type gcc.

VoOoLoX commented 7 years ago

G++ is part of GCC so it should have the same version (GCC = GNU Compiler Collection) Since it's most likely LTS release of [X]Ubuntu you gotta add test build ppa or whatever it's called in order to install latest version of anything really. I found this on askubuntu

sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install gcc-6

Try that

toddw123 commented 7 years ago

I followed a quick how-to i found online already for downloading 6.3 and getting it set up. Just running the make command on it right now to get it installed. Then ill check if the version is updated when i do gcc --version, and hopefully that will fix any issues for me.

edit: holy crap. i should of just used the method you posted for upgrading to 6.3...the make command has been running for like almost an hour. wtfffff.

Zeroeh commented 7 years ago

Doesn't gcc come preinstalled in pretty much every distro?

alanbaumgartner commented 7 years ago

@Zeroeh Can you walk me through what you did to get this working on your mac? I don't really work with anything in the C family so I am not sure how to go about it.

toddw123 commented 7 years ago

if you do it through an apt-get maybe.

VoOoLoX commented 7 years ago

@Zeroeh Yes it does, but some have older versions like Ubuntu LTS releases. On the other hand Arch is updated daily (sometimes multiple times a day) and has all latest software, which has it's positive and negative sides. It's not as stable as Ubuntu because of all the updates

Zeroeh commented 7 years ago

I installed the cmake / make dependencies through brew in the terminal. @AlanBaumgartner

Still working on getting it compiled, only messed with it for about 10 minutes before class.

toddw123 commented 7 years ago

So yesterday i tried to first install and build the latest gcc 6.3 version, but when i did gcc --version after it was finished it still showed an older number. Then i installed it through adding the repo for apt-get, and after that finished it still showed the same version number. I tried to compiled anyways and still got the same stupid errors.

So im restarting my VM just to make sure its not something dumb like it needs to be rest. If that doesnt work im just going to install arch linux on a VM so i can compile it lol.

VoOoLoX commented 7 years ago

Have you tries using gcc-6 --version ? Most likely it didn't replace the existing one but instead just installed another one with different version.

toddw123 commented 7 years ago

good idea. ive often had the kind of shit happen lol. Ill give it a try. But downloading arch linux nontheless to get it a try.

toddw123 commented 7 years ago

gcc-6 worked. But now i gotta figure out how to get the make/cmake shit to use gcc-6 instead of gcc.

edit: figured out how to switch them. used update-alternative command. hopefully the project compiles for me now.

edit2: nah its still giving me shit about the same old stuff. The unordered_map for packet handlers. Guess im giving arch linux a go.

VoOoLoX commented 7 years ago

Just before you go to Arch I gotta warn you.Arch by itself is pretty hard to install it's all done with terminal. I suggest you pick some Arch based distro which has graphical installer (Apricity, Manjaro, Antergos) these are some of the most popular ones.

toddw123 commented 7 years ago

Oh yeah dont worry i went with the one you suggested. Almost finished installing it now.

edit: i like the feel of the environment sofar. Seems similar to ubuntu atleast. But maybe thats just the boot disk environment and once its done installing itll be different idk.

toddw123 commented 7 years ago

Sweet it compiled on arch linux no problem. Just 2 warnings related to the tilemap void/int thing. Very cool.

Still not sure why it didnt/wont compile for me on my other linux machine. It might possibly be due to cmake being 3.5 instead of 3.7. Might be missing some standard libraries. idk. Im going to look into it some more later. But in the meantime im just happy it compiled.

VoOoLoX commented 7 years ago

When installing Arch you can choose what packages to install. There are few package bundles (not sure if that's the actual term) but you can choose to install base (base system stuff like kernel etc. ) and base-devel (base-devel contains a lot of development tools and libraries, almost all Arch based distros come with this development bundle, and you can install it after the system is complete as addition if you didn't install it during the system installation). Anyway I'll see if I can get this to compile properly on Ubuntu based distros since I know there is a lot more Ubuntu users out there then there is Arch users (sadly).

toddw123 commented 7 years ago

just did a little bit of cleaning up on the linux branch. Modified some of the macros and such. Made it easier for it to work on both windows and linux. I tested it on linux with a few things that i did minor tests on windows for. Now im going to pull it over to windows and double check that it still compiles correctly.

Just have to say thank you again for putting in the time to get it to compile. You are awesome man.

edit: once i get it to work for windows and updated with the most recent changes im probably just going to merge the two into the master branch. And then we will just have to make sure all code is cross-compatible from then on out. Which is completely okay with me. And luckily it looks like the code you used was only like 1 or 2 commits behind the master branch, and those commits are pretty minor things (better path-finding and whatnot). Ill see if i can get the warnings to go away for the void/int thing as well. I know when i compile on windows i try to get rid of as many warnings as possible, just like it to look cleaner when compiling lol.

VoOoLoX commented 7 years ago

About void pointer casting problem. I think you can use something called intptr_t or something like that I was lazy to try it so maybe start with that. EDIT: C++ isn't really my thing, if I focus on learning C++ I'll try to make more improvements because I think this project is great. Oh and can you close that issue about GUI Client since it's kinda dead. I moved from SDL software rendering to OpenGL and messed up the whole thing, my poor understanding of both C++ and OpenGL wouldn't get me anywhere anyway.

toddw123 commented 7 years ago

About void pointer casting problem. I think you can use something called intptr_t or something like that I was lazy to try it so maybe start with that.

Ill look into that. The thing is, the void is just being used as a basic storage device. That is how the path-finding is designed to be set up. Technically the actually content of the void can be whatever the hell we want it to be. As long as the value being cast to the void is something that i can use to determine the location its suppose to represent, then its fine. So ill check to see what other options will get rid of the warning and still allow the functionality needed.

alanbaumgartner commented 7 years ago

@Zeroeh Do you know if Xcode has similar features as visual studio with compiling? Like I said before I don't really use the C family, python and java instead, and am not too familiar with compiling C from the command line.

EDIT: It looks like it does. I am going to try and figure this out after classes are done.

toddw123 commented 7 years ago

Got more stuff cleaned up. Its much closer to the master branch now so i might attempt to merge it later tonight. Also got the EnumToString to work correctly. And i just changed the int to a long in the TileMap and it works the same and doesnt give a warning anymore.

edit: tested on both linux and windows. Both compile without issue (windows has a few warnings, but they arent anything new they have been there for a few commits now so its nothing to worry about), and both work without issue. Although i only had 1 client running for about 2 minutes on each. So ill do more testing tonight to verify it works 100%. I have no doubts that it does though.

Zeroeh commented 7 years ago

@AlanBaumgartner I don't really use xcode for any projects. It's either command line or visual studio code.

@toddw123 When you say you got it working on windows, do you mean the linux subsystem for windows?

toddw123 commented 7 years ago

Linux subsystem for Windows? What? I'm saying that the code compiles just find in visual studios on windows. I compiled it on the Linux system and then pulled the changes down to my windows system and made sure it compiled still. So the code in the Linux branch right now can be compiled on either Linux using the cmake + make command or on windows using visual studios just like normal.

Didn't get around to merging with the master branch tonight, I'll do that tomorrow. But all the code currently.in the Linux branch does exactly the same as what's in the master branch.

Zeroeh commented 7 years ago

Gonna have some fun tonight 🗡 Edit: Looks like macs don't ship with c++11 standard by default. 💥 image

alanbaumgartner commented 7 years ago

@toddw123 Yea, you can use linux bash on windows. Heres a link

toddw123 commented 7 years ago

@VoOoLoX is that screen shot in arch linux or ubuntu? And is that the code straight from the linux branch? Would be weird that it compiled just fine for me on arch but not for you. But if thats ubuntu, then i can understand lol.

@AlanBaumgartner gotcha. I have a linux vm on my computer for my work. I just use a VM like ive said before instead of trying to use a linux bash for windows.

edit: totally meant to tag @Zeroeh for the first part, im an idiot. And also an idiot because i didnt read that you clearly said "mac" lol.

toddw123 commented 7 years ago

@VoOoLoX Im closing this pull request now just because theres no reason to have the pull request sitting here still. Just create a new post in the issues section called like "Linux" and we can continue the discussion there.