Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[Box2D] error: Box2D/Box2D.h: No such file or directory

Ostatnio zmodyfikowano 2014-03-10 19:18
Autor Wiadomość
PCS
Temat założony przez niniejszego użytkownika
[Box2D] error: Box2D/Box2D.h: No such file or directory
» 2014-03-10 17:07:07
Błąd jak w tytule mi wyskakuje gdy chce uruchomić przykładowy kod z paczki oficjalnej, kod:
C/C++
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty.  In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/

#include <Box2D/Box2D.h>

#include <cstdio>

// This is a simple example of building and running a simulation
// using Box2D. Here we create a large ground box and a small dynamic
// box.
// There are no graphics for this example. Box2D is meant to be used
// with your rendering engine in your game engine.
int main( int argc, char ** argv )
{
    B2_NOT_USED( argc );
    B2_NOT_USED( argv );
   
    // Define the gravity vector.
    b2Vec2 gravity( 0.0f, - 10.0f );
   
    // Do we want to let bodies sleep?
    bool doSleep = true;
   
    // Construct a world object, which will hold and simulate the rigid bodies.
    b2World world( gravity, doSleep );
   
    // Define the ground body.
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set( 0.0f, - 10.0f );
   
    // Call the body factory which allocates memory for the ground body
    // from a pool and creates the ground box shape (also from a pool).
    // The body is also added to the world.
    b2Body * groundBody = world.CreateBody( & groundBodyDef );
   
    // Define the ground box shape.
    b2PolygonShape groundBox;
   
    // The extents are the half-widths of the box.
    groundBox.SetAsBox( 50.0f, 10.0f );
   
    // Add the ground fixture to the ground body.
    groundBody->CreateFixture( & groundBox, 0.0f );
   
    // Define the dynamic body. We set its position and call the body factory.
    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;
    bodyDef.position.Set( 0.0f, 4.0f );
    b2Body * body = world.CreateBody( & bodyDef );
   
    // Define another box shape for our dynamic body.
    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox( 1.0f, 1.0f );
   
    // Define the dynamic body fixture.
    b2FixtureDef fixtureDef;
    fixtureDef.shape = & dynamicBox;
   
    // Set the box density to be non-zero, so it will be dynamic.
    fixtureDef.density = 1.0f;
   
    // Override the default friction.
    fixtureDef.friction = 0.3f;
   
    // Add the shape to the body.
    body->CreateFixture( & fixtureDef );
   
    // Prepare for simulation. Typically we use a time step of 1/60 of a
    // second (60Hz) and 10 iterations. This provides a high quality simulation
    // in most game scenarios.
    float32 timeStep = 1.0f / 60.0f;
    int32 velocityIterations = 6;
    int32 positionIterations = 2;
   
    // This is our little game loop.
    for( int32 i = 0; i < 60; ++i )
    {
        // Instruct the world to perform a single step of simulation.
        // It is generally best to keep the time step and iterations fixed.
        world.Step( timeStep, velocityIterations, positionIterations );
       
        // Clear applied body forces. We didn't apply any forces, but you
        // should know about this function.
        world.ClearForces();
       
        // Now print the position and angle of the body.
        b2Vec2 position = body->GetPosition();
        float32 angle = body->GetAngle();
       
        printf( "%4.2f %4.2f %4.2f\n", position.x, position.y, angle );
    }
   
    // When the world destructor is called, all bodies and joints are freed. This can
    // create orphaned pointers, so be careful about your world management.
   
    return 0;
}

P-106008
PsichiX
» 2014-03-10 17:14:04
dodaj plik projektu .cbp, to będzie można sprawdzić jak podpinasz includes Box2D do projektu
P-106009
PCS
Temat założony przez niniejszego użytkownika
» 2014-03-10 17:24:07
Gdzie takowy plik się znajduje? Nie widzę go w folderze razem z projektem.
P-106012
DejaVu
» 2014-03-10 17:28:31
@up: komentarz psichiX jest w tym wypadku bezużyteczny - możesz go olać.

http://cpp0x.pl/kursy​/Kurs-SFML-2-x-C++​/Instalacja-i-konfiguracja​/Konfiguracja-SFML-2-0-Code-Bl​ocks​/464

Zobacz sobie w powyższym kursie sekcję "compiler directories" i zrób to samo dla Box2D.

W skrócie:
P-106013
PCS
Temat założony przez niniejszego użytkownika
» 2014-03-10 17:51:05
To samo, tutaj screeny, to tak. Na tym ss'ie robie tak jak w tym linku co podałeś.

Tutaj wyskakuje ten błąd:

A tutaj mam ten folder co dodaje go w Compiler Directories:
P-106020
MrPoxipol
» 2014-03-10 17:53:40
Dodaj folder piętro wyżej (w Code Blocks).
P-106021
DejaVu
» 2014-03-10 17:53:45
Usuń ze ścieżki jedno Box2D. Obecnie za 'głęboki' katalog wskazujesz.
P-106022
PCS
Temat założony przez niniejszego użytkownika
» 2014-03-10 18:05:45
Fajnie, udało się, ale jak już podałem kod powyżej to przy kompilowaniu dzieje się coś takiego:

||=== Build: Debug in Test (compiler: GNU GCC Compiler) ===|
D:\Piotrek\test\Test\Testp.cpp||In function 'int main(int, char**)':|
D:\Piotrek\test\Test\Testp.cpp|40|error: no matching function for call to 'b2World::b2World(b2Vec2&, bool&)'|
D:\...\test\Test\Testp.cpp|40|note: candidates are:|
..\..\..\c++\Projekty\Biblioteki\Box2D_v2.3.0\Box2D_v2.3.0\Box2D\Box2D\Dynamics\b2World.h|46|note: b2World::b2World(const b2Vec2&)|
..\..\..\c++\Projekty\Biblioteki\Box2D_v2.3.0\Box2D_v2.3.0\Box2D\Box2D\Dynamics\b2World.h|46|note:   candidate expects 1 argument, 2 provided|
..\..\..\c++\Projekty\Biblioteki\Box2D_v2.3.0\Box2D_v2.3.0\Box2D\Box2D\Dynamics\b2World.h|41|note: b2World::b2World(const b2World&)|
..\..\..\c++\Projekty\Biblioteki\Box2D_v2.3.0\Box2D_v2.3.0\Box2D\Box2D\Dynamics\b2World.h|41|note:   candidate expects 1 argument, 2 provided|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Tylko nie każ mi robić nowego tematu, hehe.
P-106024
« 1 » 2
  Strona 1 z 2 Następna strona