Q:

Header file with function definitions pops up LNK2005 when included into few .cpp files

I want to make some functions to use in the future, and move them to .h file to make them includable into other projects.  When I try to include that into second cpp file in the project, it can't compile with LNK2005 error.  How to fix it? 
UPD: Errors:
1>------ Build started: Project: Random Methods, Configuration: Debug Win32 ------
1>  Source.cpp
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\my\random\random.hpp(11): warning C4244: 'initializing': conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\my\random\random.hpp(31): warning C4244: '=': conversion from 'unsigned __int64' to 'unsigned int', possible loss of data
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\my\random\random.hpp(32): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
1>Source.obj : error LNK2005: "double __cdecl min(double,double)" (? min@@YANNN@Z) already defined in main.obj
1>Source.obj : error LNK2005: "int __cdecl random(int,int)" (? random@@YAHHH@Z) already defined in main.obj
1>Source.obj : error LNK2005: "float __cdecl random(float,float)" (? random@@YAMMM@Z) already defined in main.obj
1>Source.obj : error LNK2005: "double __cdecl random(double,double)" (? random@@YANNN@Z) already defined in main.obj
1>Source.obj : error LNK2005: "long double __cdecl random(long double,long double)" (? random@@YAOOO@Z) already defined in main.obj
1>Source.obj : error LNK2005: "__int64 __cdecl random(__int64,__int64)" (? random@@YA_J_J0@Z) already defined in main.obj
1>Source.obj : error LNK2005: "unsigned __int64 __cdecl random(unsigned __int64,unsigned __int64)" (? random@@YA_K_K0@Z) already defined in main.obj
1>Source.obj : error LNK2005: "bool __cdecl randomBool(void)" (? randomBool@@YA_NXZ) already defined in main.obj
1>Source.obj : error LNK2005: "bool __cdecl randomChance(double)" (? randomChance@@YA_NN@Z) already defined in main.obj
1>Source.obj : error LNK2005: "bool __cdecl randomProb(double)" (? randomProb@@YA_NN@Z) already defined in main.obj
1>Source.obj : error LNK2005: "void __cdecl randomingInit(void)" (? randomingInit@@YAXXZ) already defined in main.obj
1>Source.obj : error LNK2005: "void __cdecl swap(int,int)" (? swap@@YAXHH@Z) already defined in main.obj
1>Source.obj : error LNK2005: "unsigned __int64 * pwrs2" (? pwrs2@@3PA_KA) already defined in main.obj
1>Source.obj : error LNK2005: "unsigned __int64 rand_max_val" (? rand_max_val@@3_KA) already defined in main.obj
1>Source.obj : error LNK2005: "unsigned int rand_max_val_small" (? rand_max_val_small@@3IA) already defined in main.obj
1>Source.obj : error LNK2005: "unsigned int RANDOM_SEED" (? RANDOM_SEED@@3IA) already defined in main.obj
1>E:\Google Drive\C++\Random Methods\Debug\Random Methods.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Code:
random.hpp
//(C) AdmiralMyxtaR 20/12/2016
//stand-alone randoming from Dictionary
#ifndef ADMIRALMYXTAR_RANDOM_INCLUDED
#define ADMIRALMYXTAR_RANDOM_INCLUDED
#include <ctime>
#include <cstdlib>
using namespace std;
unsigned __int64 pwrs2[64]; //powers of two
unsigned __int64 rand_max_val; //maximum value that can be achieved by random (2^64-1)
unsigned int rand_max_val_small; 
unsigned int RANDOM_SEED = time(0);
void swap(int a, int b)
{
    int t = a;
    a = b;
    b = t;
}
double min(double a, double b) //return minimum of two values
{
    if (a > b) { return b; }
    else { return a; }
}
void randomingInit() //create powers of two array and init random generator
{
    pwrs2[0] = 1;
    for (int i = 1; i < 65; i++)
    {
        pwrs2[i] = pwrs2[i - 1] * 2;        
    }
    rand_max_val = pwrs2[64] - 1;
    rand_max_val_small = pwrs2[32] - 1;
    srand(time(0));
}
bool randomBool()
{
    return rand() % 2 == 1;
}
float random(float a, float b)
{
    float d = 0.0F;
    d += rand() % 10000 / 1e4F;
    d += rand() % 10000 / 1e8F;
    return a + d*(b - a);
}
double random(double a, double b)
{
    double d = 0.0;
    d += rand() % 10000 / 1e4;
    d += rand() % 10000 / 1e8;
    d += rand() % 10000 / 1e12;
    d += rand() % 10000 / 1e16;
    return a + d*(b - a);
}
long double random(long double a, long double b)
{
    long double d = 0.0;
    d += rand() % 10000 / 1e4L;
    d += rand() % 10000 / 1e8L;
    d += rand() % 10000 / 1e12L;
    d += rand() % 10000 / 1e16L;
    d += rand() % 10000 / 1e20L;
    d += rand() % 10000 / 1e24L;
    return a + d*(b - a);
}
__int64 random(__int64 a, __int64 b)
{
    unsigned __int64 r = 0, diff = b - a;
    for (int i = 0; i < 5; ++i)
    {
        r = (r << 15) | rand();
    }
    return a + r % (b - a + 1);
}
unsigned __int64 random(unsigned __int64 a, unsigned  __int64 b)
{
    unsigned __int64 r = 0, diff = b - a;
    for (int i = 0; i < 5; ++i)
    {
        r = (r << 15) | rand();
    }
    return a + r % (b - a + 1);
}
int random(int a, int b)
{
    unsigned int r = 0, diff = b - a;
    for (int i = 0; i < 3; ++i)
    {
        r = (r << 15) | rand();
    }
    return a + r % (b - a + 1);
}
bool randomProb(double prob) //returns whether a situation with probability prob will success(true) or fail(false)
{
    return random(0.0, 1.0) <= prob;
}
bool randomChance(double chance) //returns whether a situation with chance chance percents will success(true) or fail(false)
{
    return random(0.0, 100.0) <= chance;
}
#endif
;

main.cpp:
#include <iostream>
#include <cmath>
#include <my\random\random.hpp>
#include <chrono>
#include <thread>
using namespace std;
unsigned __int64 i = 0;
void startPerfomanceMeter()
{
    auto start = std::chrono::high_resolution_clock::now();
    while (true)
    {
        auto end = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double> elapsed = end - start;
        double t = elapsed.count();
        double T = 1e9/(i/t);
        cout << t << " s " << i / t << " Hz " << T << " ns " << endl;
        this_thread::sleep_for(500ms);
    }
}

    int main()
    {
        int t,max=-0xFFFFFFF,min=0xFFFFFFF;
        srand(time(0));
        thread perfomanceMeter(startPerfomanceMeter);
        for (i; ; i++)
        {
            t=random(13, 99999);
            if (t > max)
            {
                max = t;
                cout << (double)i << " " << " min=" << min << " max=" << max << endl;
            }
            if (t < min)
            {
                min = t;
                cout << (double)i << " " << " min=" << min << " max=" << max << endl;
            }
            //cout << random(13,666) << endl;
        }
        system("pause");
        return 0;
    }

Second cpp just has a single line - including random.hpp.  Removing all global variables and functions, dependent on them didn't fix the problem.  Using MSVS 2015 with update 3. 

A:

If you want to define the functions in the header, you must make them inline.  Otherwise you'll get multiply defined symbols if included in more than one *.cpp file. 
In the usual case the functions are just declared in the header and defined in a corresponding *.cpp file.