这是我正在使用的cmake配置

cmake_minimum_required (VERSION 3.0)

project (Project)

set (CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -O0 -DDEBUG -g")
set (CMAKE_C_FLAGS_DEBUG "-std=c++11 -O0 -DDEBUG -g")
set (CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -O3")
set (CMAKE_C_FLAGS_RELEASE "-std=c++11 -O3")

add_subdirectory (external/libwebsockets)
include_directories (external/libwebsockets/lib)

include_directories (src/globals)

add_library (libwebsockets SHARED IMPORTED)

add_executable (Project src/main.c)

target_link_libraries (Project libwebsockets)


Libwebsockets已作为external/libwebsockets下的git子模块添加。使用上述配置进行构建时出现以下错误

In file included from /home/Project/server/src/main.c:2:0:
/home/Project/server/external/libwebsockets/lib/libwebsockets.h:43:24: fatal error: lws_config.h: No such file or directory
compilation terminated.
CMakeFiles/Project.dir/build.make:62: recipe for target 'CMakeFiles/Project.dir/src/main.c.o' failed
make[2]: *** [CMakeFiles/Project.dir/src/main.c.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Project.dir/all' failed
make[1]: *** [CMakeFiles/Project.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2


有人可以帮我解决我要去的地方以及如果我正确编写CMake配置脚本吗?

最佳答案

找不到以下文件:


  lws_config.h:没有这样的文件或目录
  编译终止。


从第43行的libwebsockets.h引用时:


  libwebsockets.h:43:24:


这是在编译main.c时生成的:


  在/home/Project/server/src/main.c:2:0中包含的文件中:


您知道子模块树中是否有“ lws_config.h”吗?

关于c - 无法使用CMake编译libwebsockets?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44536189/

10-11 21:23