这个错误提示是因为你的目标“interpreter”是一个OBJECT_LIBRARY类型的库,不能被链接到另一个目标上。解决方法是将目标类型改为STATIC或SHARED库,或者将链接目标设置为具有ENABLE_EXPORTS属性的可执行文件。具体步骤如下:

  1. 将目标类型改为STATIC或SHARED库。在CMakeLists.txt中,使用add_library()函数时,将第一个参数指定为库的名称,第二个参数指定为库的类型,例如:
add_library(interpreter STATIC ${SRC_FILES})
  1. 将链接目标设置为具有ENABLE_EXPORTS属性的可执行文件。在CMakeLists.txt中,使用target_link_libraries()函数时,将链接目标指定为具有ENABLE_EXPORTS属性的可执行文件,例如:
target_link_libraries(my_target PRIVATE my_library)
set_target_properties(my_target PROPERTIES ENABLE_EXPORTS true)

这样做就可以解决这个错误提示了

Target interpreter of type OBJECT_LIBRARY may not be linked into another target One may link only to STATIC or SHARED libraries or to executables with the ENABLE_EXPORTS property set如何解决

原文地址: https://www.cveoy.top/t/topic/fsup 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录