如何在Visual Studio Code(Windows10)中包含用于MuJoCo模拟的GTK库

0qx6xfy6  于 2024-01-06  发布在  Windows
关注(0)|答案(1)|浏览(218)

我想做的是
我正在练习MuJoCo模拟,基于Pranav Bhouncent的YouTube lecture
本讲座中,模拟的代码用C语言编写,并提供了运行模拟的makefile(如下)。

COMMON=/O2 /MT /EHsc /arch:AVX /I../../include /Fe../../bin/
    LIBS = ../../lib/glfw3dll.lib  ../../lib/mujoco.lib 
    CC = cl

    ROOT = project_name

    all:
        $(CC) $(COMMON) main.c $(LIBS) -o ../../bin/$(ROOT)

    main.o:
    $(CC) $(COMMON) -c main.c

    clean:
    rm *.o ../../bin/$(ROOT)

字符串
我一直在Visual Studio 2022中工作,直到现在都很好。
目前,我想使用GTK-3.0库添加GUI组件,我使用vcpkg安装了GTK-3.0。
我在Visual Studio 2022中练习了一些GTK的例子,它工作得很好。
现在,我正在尝试 * 在MuJoCo模拟代码中添加GTK库 *,这样我就可以在Visual Studio Code中集成我的模拟项目(我听说使用VSCode更好,因为它是轻量级的,多功能的,.

我的项目目录详情

基本上,我的MuJoCo项目的构造如下。

|-- include
|   |-- GLFW            // include GLFW headers e.g. glfw3.h, ...
|   |-- mujoco          // include mujoco headers e.g. mujoco.h, ...
|-- lib                 // include libraries e.g. glfw3dll.lib, mujoco.lib
|-- myProject
|   |-- project_name
|   |   |-- main.c      // this is the main code for MuJoCo simulation
|   |   |-- makefile    // makefile for complie as shown in above.
|   |   |-- run_win.bat // batch file for executing the simulation


另外,我使用vcpkg在以下目录中安装了GTK库。C:/.../vcpkg/installed/x64-windows

|-- bin             // include GTK-related .dll files
|-- ...
|-- include         // include GTK-related header files
|   |-- atk-1.0
|   |-- cairo
|   |-- gtk-3.0
|       |-- gdk
|       |-- gtk     // gtk.h, ...
|   |-- ...
|-- lib             // include GTK-related .lib files
|   |-- gdk-pixbuf-2.0
|   |-- glib-2.0
|   |-- ...
|-- ...

问题陈述

正如我上面提到的,我试图在VSCode中包含MuJoCo项目的GTK库。

#include <GLFW/glfw3.h>
    #include <mujoco/mujoco.h>
    #include <gtk-3.0/gdk/gtk.h>


但是,当我累了运行模拟(即使没有包括GTK库),错误发生在终端,这样;

gcc -c -g main.c ../../lib/glfw3dll.lib ../../lib/mujoco.lib
    main.c:9:10: fatal error: GLFW/glfw3.h: No such file or directory
        9 | #include <GLFW/glfw3.h>
    compilation terminated.


(The对于mujoco.h或gtk.h也发生类似错误。)
我猜它甚至找不到GLFW和mujoco头的目录(我不知道为什么)。我已经在[C/C++扩展包:智能感知包] - [包含路径]中包含了头的路径,如下所示。

${workspaceFolder}/**
    C:\...\mujoco-2.2.1-windows-x86_64\include\**
    C:\...\mujoco-2.2.1-windows-x86_64\lib\**
    C:\...\vcpkg\installed\x64-windows\include\**
    C:\...\vcpkg\installed\x64-windows\lib\**


(我没有按字面意思输入'...'。'...'表示我省略的路径的中间。我实际上输入了所有的路径。)
我想我已经正确地包含了GLFW,mujoco和GTK的库和头文件的路径。但是终端说它找不到这样的文件或目录。

  • 所以,我想问我错过了什么或做错了什么,我应该改变什么才能包含GTK库并正确运行模拟。

仅供参考

  • 当我在VS 2022中练习GTK示例时,我在[Property Manager]-[VC++ Directories,C/C++,Linkger]中正确地包含了所有.dll文件、头文件和.lib文件。
  • 当我在VS 2022中运行模拟时,我使用'cl'作为编译器,使用'nmake'构建代码,并在终端中输入'run_win. bat'以运行模拟。
  • 在VSCode中,我安装了MinGW,以便使用'gcc'作为编译器,并编辑了批处理文件,如下所示,使用'mingw 32-make'构建代码。
mingw32-make
    SET var=%cd%
    cd ../../bin && quad_leg_floating
    cd %var%

  • 在C/C++中,我选择了[编译器路径]作为'C:/MinGW/bin/gcc.exe',[智能感知模式]作为'windows-gcc-x64'。

正如我之前提到的,
当我在VS 2022中练习MuJoCo模拟时,使用指定的makefile(使用cl编译器),我可以通过在命令'nmake'的终端中键入'run_win. bat'来运行模拟。
现在,当我试图在VSCode中运行相同的模拟时,我试图使用gcc作为编译器并编辑批处理文件'mingw 32-make'进行构建,但它不起作用。
我尝试在'settings.json'中添加一些设置,如下所示,但它也不起作用。

"C_Cpp.default.includePath": [
        "C:/.../mujoco-2.2.1-windows-x86_64/include/mujoco",
        "C:/.../mujoco-2.2.1-windows-x86_64/include/GLFW"
     ]

0mkxixxg

0mkxixxg1#

如果您正在构建GUI,则可以使用mujoco中提供的GUI,请参阅文件simulate. c
下面是一个准系统模拟文件,您可以修改。https://pab47.github.io/reports/MuJoCo%20UI%20Projectile%20Game.zip

相关问题