对应于 C++ 中的 main 函数的编译时错误
Compile-time error corresponding to main function in C++
这是我的编译命令,后面是我收到的错误消息。
您可以看到代码的 link 也已附上。
g++ -Wall `root-config --cflags --ldflags --libs` StevenJohnsonDoubleIntegration.cpp
/usr/lib/gcc/i686-redhat-linux/4.9.2/../../../crt1.o: In function `_start':(.text+0x18): undefined reference to `main'
collect2:错误:ld 返回了 1 个退出状态
错误 undefined reference to main 意味着在链接时,没有 main()
函数。
查看示例代码,有一条评论说:
Compile with -DTEST_INTEGRATOR to generate this little test
program.
Usage: ./integrator <dim> <tol> <integrand> <maxeval>
where = # dimensions, = relative tolerance,
is either 0/1/2 for the three test integrands (see below),
and is the maximum # function evaluations (0 for none).
查看代码,除非定义此符号,否则 main 函数将被排除在构建之外。
因此,将-DTEST_INTEGRATOR
添加到您的命令行进行编译。您可能还需要一个 -o integrator
来使输出名为 integrator
而不是 a.out
g++ -DTEST_INTEGRATOR -Wall `root-config --cflags --ldflags --libs` StevenJohnsonDoubleIntegration.cpp -o integrator
这是我的编译命令,后面是我收到的错误消息。 您可以看到代码的 link 也已附上。
g++ -Wall `root-config --cflags --ldflags --libs` StevenJohnsonDoubleIntegration.cpp
/usr/lib/gcc/i686-redhat-linux/4.9.2/../../../crt1.o: In function `_start':(.text+0x18): undefined reference to `main'
collect2:错误:ld 返回了 1 个退出状态
错误 undefined reference to main 意味着在链接时,没有 main()
函数。
查看示例代码,有一条评论说:
Compile with -DTEST_INTEGRATOR to generate this little test program.
Usage: ./integrator <dim> <tol> <integrand> <maxeval>
where = # dimensions, = relative tolerance,
is either 0/1/2 for the three test integrands (see below), and is the maximum # function evaluations (0 for none).
查看代码,除非定义此符号,否则 main 函数将被排除在构建之外。
因此,将-DTEST_INTEGRATOR
添加到您的命令行进行编译。您可能还需要一个 -o integrator
来使输出名为 integrator
而不是 a.out
g++ -DTEST_INTEGRATOR -Wall `root-config --cflags --ldflags --libs` StevenJohnsonDoubleIntegration.cpp -o integrator