Log in

View Full Version : Compiling c++ Scripts



Joethlon
09-09-2012, 03:15 PM
All right, as a coding noob, I've been trying for hours to compile these scripts (here (https://www.vaultmp.com/showwiki.php?title=Saving+items+of+players) & here (https://www.vaultmp.com/showwiki.php?title=Saving+position+of+players)). I've been using Visual Studio 2010 and I can't for the life of me figure out how to compile these as the necessary .dll/shared object files. Trawling through google yielded no results - that I could understand at least - and as a result I'm wondering if any of you could help me?

foxtacles
09-09-2012, 05:10 PM
vaultmp scripts require a C++11 compiler. I don't know how much of C++11 is already implemented in VC++. You probably need the most recent version (Visual Studio 2012).

https://www.cpprocks.com/a-comparison-of-c11-language-support-in-vs2012-g-4-7-and-clang-3-1/

I see at least three C++11 features which are lacking in VC++ but required by vaultmp. So you either have to wait for Microsoft to release an updated version of the compiler or use GCC 4.7.1 (MinGW when on Windows) or Clang.

I'm using GCC. My recommendation is to install Code::Blocks, then overwriting MinGW with this version:

https://sourceforge.net/projects/mingwbuilds/files/windows-host/4.7.1/release/

Joethlon
09-09-2012, 06:16 PM
EDIT: After messing around with it a bit I found that adding '-std=gnu++0x -U__STRICT_ANSI__' to 'other options' in the compiler settings fixes the below problem, I get a 'lib(projectname).dll' file when I compile yet I still get these two errors:



obj\Release\itemsave.o:itemsave.cpp:(.text+0x2d0): multiple definition of `OnPlayerDisconnect'
obj\Release\positionsave.o:positionsave.cpp:(.text +0x1a0): first defined here


Also the vaultserver says it can not find the script.



I've overwritten MinGW with that version and started a .dll project in Code::Blocks which I added the two scripts two as a .cpp source along with the vaultscript.h. Now I must be doing something horribly wrong but when I go 'Build << Build' it returns with numerous errors, most notably this file appears in the window:



// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.


// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.


// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.


// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <https://www.gnu.org/licenses/>.


/** @file include/c++0x_warning.h
* This is a Standard C++ Library header.
*/


#ifndef VAULTCXX0X_WARNING_H
#define VAULTCXX0X_WARNING_H 1


#ifndef __GXX_EXPERIMENTALVAULTCXX0X__
#error This file requires compiler and library support for the upcoming \
ISO C++ standard, C++0x. This support is currently experimental, and must be \
enabled with the -std=c++0x or -std=gnu++0x compiler options.
#endif


#endif

foxtacles
09-10-2012, 12:17 AM
You can define a callback only once per script; either merge the contents of both scripts and their callbacks into one compilation unit by hand, or compile both scripts separately (into two object files).

Joethlon
09-10-2012, 05:03 PM
Thanks for the help so far Recycler, been great :), I compiled the .dll's flawlessly but now it's showing a 'could not load' error in the vaultserver.

143

foxtacles
09-10-2012, 05:56 PM
Did you compile as static library? (append -static to linker options)

Else you need the GCC dynamic libraries installed on your Windows machine:

libstdc++-6.dll
libwinpthread-1.dll
libgcc_s_sjlj-1.dll

(those DLLs are in your MinGW files somewhere, but need to be copied into Windows/ or to vaultserver exectuable place)

Joethlon
09-10-2012, 06:10 PM
Not sure how to go about giving you those things, but here's a mediafire link for the Code::Blocks projects. https://www.mediafire.com/?6y619chk0smq84b

foxtacles
09-10-2012, 06:17 PM
Compile as static library:

https://i.imgur.com/0XU3J.png
(then Rebuild)

Or copy the DLLs as stated above.

Joethlon
09-10-2012, 06:53 PM
Still getting the same error after trying both suggestions :L

foxtacles
09-10-2012, 06:58 PM
I compiled your scripts and they work for me. They should be about ~160kb in size if you linked statically.

Joethlon
09-10-2012, 07:07 PM
Both scripts compile to either 182Kb or 183Kb, could it be that this is not set up properly?

145

Smoria
09-10-2012, 07:13 PM
I had the same error until I installed this compiler
code.google.com (https://code.google.com/p/pcxprj/downloads/detail?name=MinGW64CRT_4.7.1.20120501_static_win32 .7z&can=4&q=)