【问题标题】:Including brew installed library to XCode将 brew 安装的库包含到 XCode
【发布时间】:2020-05-01 14:51:51
【问题描述】:

我正在尝试使用 Raylib 创建游戏。我想使用 XCode,因为我认为库管理与 Windows 上的 Visual Studio 一样简单。

我使用brew install raylib 安装了库。现在我尝试运行我从 Raylib 网站复制的这个简单项目。

main.c:

#include "raylib.h"
#include <stdio.h>

int main(void)
{
    // Initialization
    //--------------------------------------------------------------------------------------
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");

    Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };

    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f;
        if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f;
        if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f;
        if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f;
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(RAYWHITE);

            DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY);

            DrawCircleV(ballPosition, 50, MAROON);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}

我包括了搜索路径和标题路径,如下图所示:

代码构建得很好,但没有启动终端会话,也没有绘制球。您还可以在图片中看到该库未加载,但我不明白为什么。我还对我包含的库和框架进行了截图:

任何帮助将不胜感激。

【问题讨论】:

    标签: c++ c xcode macos


    【解决方案1】:

    找到this post解决了

    我刚刚从项目中删除了库验证。

    【讨论】:

      猜你喜欢
      • 2017-12-19
      • 2015-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-24
      • 2019-12-22
      • 1970-01-01
      相关资源
      最近更新 更多