首页 > 解决方案 > Cmake 配置不完整,出现错误 | Box2d / Linux

问题描述

我无法配置 cmake。问题如下所述,关于我无法充分利用它:

CMake error at /snap/cmake/936/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake230 (message):Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)

Call Stack (most recent call first):
/snap/cmake/936/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake594 (_FPHSA_FAILURE_MESSAGE)

/snap/cmake/936/share/cmake-3.21/Modules/FindXII.camke:457 (find_package_handle_Standard_args)
extern/glfx/CMakeLists.txt:27 (find package)

以下是错误日志(CmakeErrorLog):

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_81640/fast && /usr/bin/make  -f CMakeFiles/cmTC_81640.dir/build.make CMakeFiles/cmTC_81640.dir/build
make[1]: Entering directory '/home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_81640.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_81640.dir/src.c.o -c /home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_81640
/snap/cmake/936/bin/cmake -E cmake_link_script CMakeFiles/cmTC_81640.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_81640.dir/src.c.o -o cmTC_81640 
/usr/bin/ld: CMakeFiles/cmTC_81640.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x5e): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x6f): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_81640.dir/build.make:99: cmTC_81640] Error 1
make[1]: Leaving directory '/home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_81640/fast] Error 2


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_f6423/fast && /usr/bin/make  -f CMakeFiles/cmTC_f6423.dir/build.make CMakeFiles/cmTC_f6423.dir/build
make[1]: Entering directory '/home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_f6423.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_f6423.dir/CheckFunctionExists.c.o -c /snap/cmake/936/share/cmake-3.21/Modules/CheckFunctionExists.c
Linking C executable cmTC_f6423
/snap/cmake/936/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f6423.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_f6423.dir/CheckFunctionExists.c.o -o cmTC_f6423  -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_f6423.dir/build.make:99: cmTC_f6423] Error 1
make[1]: Leaving directory '/home/hariton/Box2D/Box2D/Testbed/Build/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_f6423/fast] Error 2

输出日志太大,我无法发布(也许可以发布部分内容)。

我很肯定我已经安装了所有需要的库。问题必须出在 cmake 实现上。所做的是以下在此处输入图像描述 基本上我在 CMake 主文件中,我想在 box2d 的 testbed 文件夹中运行它。

谁能帮帮我?

如果需要更多信息,请告诉我

标签: cmakebox2d

解决方案


最终能够正确配置 cmake

最初的问题是因为没有安装以下库:x11-dev

然后出现了另一个错误,如上述评论中所述。安装以下 xorg-dev libglu1-mesa-dev 后,配置完成,没有任何错误。

谢谢两位的帮助!


推荐阅读