zeb*_*und 1 c++ compilation cmake linker-errors
当我尝试使用编译程序时make
,出现了对主错误的未定义引用。但是,main存在于我的src目录中,我对自己做错的事情感到困惑。
我假设这add_executable([title] [source])
是用于将源文件添加到编译中的命令。
基于cmake教程
cmake_minimum_required(VERSION 2.6)
project(opengl_02)
add_executable(opengl_02 opengl_02.cpp)
add_executable(main main.cpp)
add_executable(geometrics geometrics.cpp)
set (opengl_02_version_major 1)
set (openfl_02_version_minor 0)
#configure the header file to pass some of the CMake settings
#to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/opengl_02_config.h.in"
"${PROJECT_BINARY_DIR}/opengl_02_config.h"
)
#add the binary tree to the search path for include files
#so that it will find tutorialconfig.h
include_directories("{PROJECT_BINARY_DIR}")
add_executable(opengl_02_config opengl_02_config.cpp)
Run Code Online (Sandbox Code Playgroud)
题
为什么我的主文件没有被引用?
小智 6
int main (int argc, char *argv[])
(或没有参数的等效项)必须存在于每个程序中。这是很难说有什么不对您的设置不看源代码,但是我有一种感觉,主要的功能是不存在于每个文件,您正试图编译成可执行文件,即opengl_02.cpp
,geometrics.cpp
或main.cpp
。如果您确实要创建三个可执行文件,则main
函数应在示例中的所有三个源文件中都存在。如果要从三个源文件创建可执行文件,则必须为一个可执行文件指定所有文件,例如add_executable(main main.cpp opengl_02.cpp geometrics.cpp)
。希望能帮助到你。
归档时间: |
|
查看次数: |
5782 次 |
最近记录: |