minerCPP
Compiling minerCPP - Printable Version

+- minerCPP (./)
+-- Forum: minerCPP (/forumdisplay.php?fid=3)
+--- Forum: Support (/forumdisplay.php?fid=12)
+--- Thread: Compiling minerCPP (/showthread.php?tid=51)


Compiling minerCPP - Dandistine - 03-09-2010 04:36 AM

Sometimes it is nice to compile software yourself, just for safety's sake.

I noticed there were a few people that couldn't get minerCPP to compile, so I made this quick (image heavy) tutorial to guide you through. While the project used in the tutorial is specific to minerCPP, the basic process is essentially the same for other software, even those written in different languages.

ALL THE IMAGES ARE CUT OFF. TO VIEW THE ENTIRE IMAGE, RIGHT CLICK AND HIT "VIEW IMAGE". I WAS TOO LAZY TO SHRINK THESE.

To start, I will be using Microsoft Visual Studio Professional Edition. You can use the Microsoft Visual C++ Express Edition if you like, you just wont have the bells and whistles I do (none of them are actually used here). You will need to first open the program (no shit right?):

[Image: Step1.jpg]

Relatively simple stuff so far. Next we need a project file. The project is Visual Studio's way of keeping track of where all your code is placed. It also determines some basic build rules, and the type of program that you will make.

[Image: Step2.jpg]

Now we need to determine what kind of project we want. minerCPP in specific is considered a "Console Application" and needs to be created as such. In the project window, select the "Win32" project type, and then the "Win32 Console Application" template. Give it a name, and the default directory is probably fine.

[Image: Step3.jpg]

On the next screen, click "Next".

[Image: Step4.jpg]

You will notice some basic application settings. Ensure that "Console Application" is selected and check off "Empty Project" as in the picture. Now hit finish.

[Image: Step5.jpg]

On the left is a "Solution Explorer". This is a visualization of your project. If you do not have a Solution Explorer, click View -> Solution Explorer. Once your explorer is sorted out, right click any folder (I use source because I want too) and click Add -> Existing Item.

[Image: Step6.jpg]

Now locate the folder that the source files that you downloaded are contained. In my picture you see green check marks on them, this is from SVN. You may or may not have these, they are not important for this. Select all your source files (everything in the trunk folder) and click "Add".

[Image: Step7.jpg]

Now all the source files will appear in your Solution Explorer. You can double click and view these if you want, but modification should not be needed.

[Image: Step8.jpg]

Now we need to compile the project so we can run it. Click Build -> Rebuild Solution. If "Rebuild Solution" is not an option, just use "Build".

[Image: Step9.jpg]
Ok so now it is compiling. You will get a load of warnings, all of which can be ignored for now. At the very bottom however, there is an error about zlib. Let's examine this. ZLIB is a compression library. A library contains functions and code that your programs can use, if you tell them too do so. minerCPP uses ZLIB, and so we need to make sure the project knows that.

[Image: Step10.jpg]

Go and download the ZLIB binaries. Unzip the file, and READ THE INSTRUCTIONS. I can not stress this enough, read every read-me file that is provided. In the read-me are instructions on how to include ZLIB. Follow the three steps. For simplicity (and because I'm a bit lazy) I will only show the last one. Right click one of the folders, and click Add -> Existing Item and find the zlib.lib that you downloaded and add that file.

[Image: Step11.jpg]

You should get a pop-up about a "Custom Build Rule". Click "No", if you didn't get a pop-up, then you are in the clear.

[Image: Step12.jpg]

Now you need to build your project again, the same way we did up above.

[Image: Step13.jpg]

This time to build succeeded, and you should find an executable in "<project location>/Debug/" but we don't want this one. Debug is used to find and fix bugs. These executables are very large, and contain extra code to help Visual Studio detect bugs. We want a "Release" file, one that does not have the debug information contained within it. Look up top and you should see a dropdown box that says "Debug" which is to the left of a play button. Change it to say "Release", and rebuild.

[Image: Step14.jpg]



That should do it for compiling your own server. These same steps will work as a general method for other software and coding languages as well. What will change is the "Project Type" that we selected earlier based on the language and type of software. Some languages use non-Microsoft compilers, but even these generally follow the same basic steps. Create a project, select type, add your source, compile, add missing libraries, compile again.

If you have questions on specifics, or methods, just drop them here. If you have questions on ZLIB and you did not follow ZLIB's directions, then don't ask until you did what they require first.


RE: Compiling MienrCPP - dag10 - 03-09-2010 06:12 AM

Nice guide!


RE: Compiling MienrCPP - strykermikado - 03-09-2010 06:52 AM

Excellent tutorial. I was thinking about trying to code some custom commands.


RE: Compiling MienrCPP - dag10 - 03-09-2010 06:56 AM

OH, Lol:
You misspelles "minerCPP" in the thread title.

Sad


RE: Compiling MienrCPP - strykermikado - 03-09-2010 07:48 AM

Maybe its intentional and nazis bought them out. Tongue


RE: Compiling MienrCPP - PyroPyro - 03-09-2010 07:50 AM

(03-09-2010 06:56 AM)dag10 Wrote:  OH, Lol:
You misspelles "minerCPP" in the thread title.
Sad

It's fixed Big Grin


RE: Compiling minerCPP - NickSlash - 03-12-2010 01:57 AM

Ive downloaded the source from the svn and attempted a couple of times to compile either of the versions on there but I cant get them to work Sad

C++ isn't really my language (basic understanding of how it works etc, just so you know)

Ive followed your guide and read the bits that came with zlib and the zlib problems went away.

when compiling the code in trunk i get one error:
Code:
1>network.cpp(59) : error C4716: 'Network::step' : must return a value

and with the branch code, i get 4 errors:
Code:
1>server.cpp(1854) : error C2086: 'std::vector<_Ty> backupFiles' : redefinition
1>        with
1>        [
1>            _Ty=backupFile
1>        ]
1>server.cpp(1848) : see declaration of 'backupFiles'
1>server.cpp(1855) : error C2086: 'backupFile f' : redefinition
1>server.cpp(1849) : see declaration of 'f'
1>server.cpp(1856) : error C2086: 'WIN32_FIND_DATA FindFileData' : redefinition
1>server.cpp(1850) : see declaration of 'FindFileData'
1>server.cpp(1857) : error C2374: 'DirSpec' : redefinition; multiple initialization
1>server.cpp(1851) : see declaration of 'DirSpec'

If its a simple problem, and you care to enlighten me i would be grateful (?), if not i'll just go back to the code in the zip file as that works fine.

Thanks


RE: Compiling minerCPP - TheJCS - 03-12-2010 10:22 AM

(03-12-2010 01:57 AM)NickSlash Wrote:  Ive downloaded the source from the svn and attempted a couple of times to compile either of the versions on there but I cant get them to work Sad

C++ isn't really my language (basic understanding of how it works etc, just so you know)

Ive followed your guide and read the bits that came with zlib and the zlib problems went away.

when compiling the code in trunk i get one error:
Code:
1>network.cpp(59) : error C4716: 'Network::step' : must return a value

and with the branch code, i get 4 errors:
Code:
1>server.cpp(1854) : error C2086: 'std::vector<_Ty> backupFiles' : redefinition
1>        with
1>        [
1>            _Ty=backupFile
1>        ]
1>server.cpp(1848) : see declaration of 'backupFiles'
1>server.cpp(1855) : error C2086: 'backupFile f' : redefinition
1>server.cpp(1849) : see declaration of 'f'
1>server.cpp(1856) : error C2086: 'WIN32_FIND_DATA FindFileData' : redefinition
1>server.cpp(1850) : see declaration of 'FindFileData'
1>server.cpp(1857) : error C2374: 'DirSpec' : redefinition; multiple initialization
1>server.cpp(1851) : see declaration of 'DirSpec'

If its a simple problem, and you care to enlighten me i would be grateful (?), if not i'll just go back to the code in the zip file as that works fine.

Thanks

Yeah, samething here. I think it's because they haven't finished these stuff yet.

(You can fix the trunk error, adding a return value, but you will get a run time exception...)


RE: Compiling minerCPP - Twdtwd - 03-12-2010 11:29 AM

I didn't see those because of my compiler. They will be updated and fixed in the next few hours.

-Twdtwd


RE: Compiling minerCPP - strykermikado - 03-12-2010 07:58 PM

I keep getting "error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'". Nothing I do will fix it. Plus there are a few more errors that produce when I try to compile rev620.

Code:
1>..\..\..\..\..\Desktop\Minecraft\Compile Server\branch\Server.cpp(1976) : error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::append(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax> &'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        Reason: cannot convert from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax>'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>..\..\..\..\..\Desktop\Minecraft\Compile Server\branch\Server.cpp(1990) : error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::append(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax> &'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        Reason: cannot convert from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax>'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        No constructor could take the source type, or constructor overload resolution was ambiguous



RE: Compiling minerCPP - NickSlash - 03-13-2010 05:07 AM

Twdtwd: what compiler do you use?


RE: Compiling minerCPP - TheJCS - 03-13-2010 05:38 AM

(03-12-2010 07:58 PM)strykermikado Wrote:  I keep getting "error C2664: 'CreateDirectoryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'". Nothing I do will fix it. Plus there are a few more errors that produce when I try to compile rev620.

Code:
1>..\..\..\..\..\Desktop\Minecraft\Compile Server\branch\Server.cpp(1976) : error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::append(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax> &'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        Reason: cannot convert from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax>'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>..\..\..\..\..\Desktop\Minecraft\Compile Server\branch\Server.cpp(1990) : error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::append(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax> &'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        Reason: cannot convert from 'WCHAR [260]' to 'const std::basic_string<_Elem,_Traits,_Ax>'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>,
1>            _Ax=std::allocator<char>
1>        ]
1>        No constructor could take the source type, or constructor overload resolution was ambiguous

This error could be fixed by adding adding the L prefix before the first argument of CreateDirectoryW, but I don't think this is the problem.

I've managed to compile the source code of the stable release by creating a new Empty Project (not a Console App). You will need to add both libs and the include path for zlib, of course.

But I'd sugest you to use the SVN version, it comes with a VC project, you just need to open and compile...


RE: Compiling minerCPP - strykermikado - 03-13-2010 05:44 AM

See I had actually tried that but to no avail. I have included the zlibs and what not. When I changed the project over to multi-byte char set, this error went away and then gave me an error saying I need the winsock libs which are only come from the sdk from microsoft that is much bigger then I care to download.


RE: Compiling minerCPP - NickSlash - 03-13-2010 06:05 AM

@TheJCS: your right, the vcprojects do compile... I'm certain I tried it/them a couple of days ago to no avail.

Thanks


RE: Compiling minerCPP - Dandistine - 03-13-2010 03:30 PM

paste in the lines of code that are throwing the errors. You probably just need to add "(LPCWSTR)" in front of the value that it can't convert.

dag and Twd have (or had) automatic type casting enabled for their projects (it is disabled by default) which lets their compiler make the necessary adjustments. This creates runnable code for them, but it will fail for people who dont have auto type casting enabled.