lundi 21 novembre 2016

C++:compilation error:"cstdlib: No such file or directory compilation terminated"

I work on ubuntu16.04 on VirtualBox and I want to use "Rand()" function, in order to do so I've included "cstdlib" and "ctime" but I get a fatal error when compiling.

this is my code:

#include "../include/Deck.h"
#include <iostream>
#include <vector>
#include <stack>
#include <csdtlib>
#include <ctime>

using namespace std;

Deck::Deck (int maxNum)
{
    int j=2;
    int chooser=0;
    vector <Card*> allCards;
    for (int i=0; i<=maxNum*4; i+4)
{
    allCards[i] = new NumericCard(Diamond,j);
    allCards[i+1] = new NumericCard(Club,j);
    allCards[i+2] = new NumericCard(Heart,j);
    allCards[i+3] = new NumericCard(Spade,j);
    j++;
}
allCards[(maxNum+3)*4-16] = new FigureCard(Diamond,Jack);
allCards[(maxNum+3)*4-15] = new FigureCard(Club,Jack);
allCards[(maxNum+3)*4-14] = new FigureCard(Heart,Jack);
allCards[(maxNum+3)*4-13] = new FigureCard(Spade,Jack);
allCards[(maxNum+3)*4-12] = new FigureCard(Diamond,Queen);
allCards[(maxNum+3)*4-11] = new FigureCard(Club,Queen);
allCards[(maxNum+3)*4-10] = new FigureCard(Heart,Queen);
allCards[(maxNum+3)*4-9] = new FigureCard(Spade,Queen);
allCards[(maxNum+3)*4-8] = new FigureCard(Diamond,King);
allCards[(maxNum+3)*4-7] = new FigureCard(Club,King);
allCards[(maxNum+3)*4-6] = new FigureCard(Heart,King);
allCards[(maxNum+3)*4-5] = new FigureCard(Spade,King);
allCards[(maxNum+3)*4-4] = new FigureCard(Diamond,Ace);
allCards[(maxNum+3)*4-3] = new FigureCard(Club,Ace);
allCards[(maxNum+3)*4-2] = new FigureCard(Heart,Ace);
allCards[(maxNum+3)*4-1] = new FigureCard(Spade,Ace);
for (int i=0; i<=(maxNum+3)*4; i++)
{
    chooser = rand() % (maxNum+3)*4-i;
    deck.push(allCards[chooser]);
    allCards.erase(chooser);
}
}

this is my makefile:

all: ../src/Card.o ../src/Deck.o
Card.o: ../include/Card.h ../src/Card.cpp
    g++ -Wall -c ../src/Card.cpp

Deck.o: ../include/Deck.h ../src/Deck.cpp
    g++ -wall -c ../src/Deck.cpp

    g++ -o Card.o Deck.o

and this is what i get from the compiler:

g++    -c -o ../src/Deck.o ../src/Deck.cpp
../src/Deck.cpp:5:19: fatal error: csdtlib: No such file or directory
compilation terminated.
<builtin>: recipe for target '../src/Deck.o' failed
make: *** [../src/Deck.o] Error 1

how can I solve this?




Aucun commentaire:

Enregistrer un commentaire