提问人:puccj 提问时间:4/21/2023 最后编辑:starballpuccj 更新时间:4/22/2023 访问量:221
使用 cmake 构建时出错:未定义对“__imp__dupenv_s”的引用
Error while build with cmake: undefined reference to `__imp__dupenv_s'
问:
我正在尝试下载和使用一个库(matplot++),它没有满足我需求的预编译版本(Windows 和 MinGW 编译器)。另一个库 (opencv) 也发生了同样的事情,但我能够使用 CMake 并遵循本指南从源代码编译它。
我尝试从终端和 gui 配置 CMake,在这两种情况下我都得到了“配置完成”和“生成完成”。但是,当我尝试构建(或)构建到达 4% 时,我收到此错误:cmake --build .
mingw32-make install
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../source/matplot/libmatplot.a(gnuplot.cpp.obj):gnuplot.cpp:(.text+0x506d): undefined reference to `__imp__dupenv_s'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [examples\line_plot\plot\CMakeFiles\example_plot_1.dir\build.make:101: examples/line_plot/plot/example_plot_1.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:4006: examples/line_plot/plot/CMakeFiles/example_plot_1.dir/all] Error 2
mingw32-make: *** [Makefile:165: all] Error 2
这只是我第二次使用 cmake,我真的不明白这是如何工作的或该怎么做。我在网上和 matplot++ 的 github 问题上搜索过,但一无所获。
我正在使用: CMake 版本:
3.26.3 g++(Rev10,由 MSYS2 项目构建) 12.2.0
gcc(Rev10,由 MSYS2 项目构建)12.2.0
全输出
C:\Users\Daniele\Desktop\matplotplusplus-1.1.0\build>mingw32-make install
[ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/algebra.cpp.obj
[ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/fruchterman_reingold.cpp.obj
[ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/kamada_kawai.cpp.obj
[ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/layout.cpp.obj
[ 0%] Building CXX object source/3rd_party/CMakeFiles/nodesoup.dir/nodesoup/src/nodesoup.cpp.obj
[ 1%] Linking CXX static library libnodesoup.a
[ 1%] Built target nodesoup
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/backend/backend_interface.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/backend/gnuplot.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/backend/backend_registry.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/axes_type.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/axes_object.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/axis_type.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/figure_type.cpp.obj
[ 1%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/figure_registry.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/legend.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/core/line_spec.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/colors.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/common.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/contourc.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/world_cities.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/world_map_10m.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/world_map_50m.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/util/world_map_110m.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/bars.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/box_chart.cpp.obj
[ 2%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/circles.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/contours.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/error_bar.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/filled_area.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/function_line.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/histogram.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/labels.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/line.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/matrix.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/network.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/parallel_lines.cpp.obj
[ 3%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/stair.cpp.obj
[ 4%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/string_function.cpp.obj
[ 4%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/surface.cpp.obj
[ 4%] Building CXX object source/matplot/CMakeFiles/matplot.dir/axes_objects/vectors.cpp.obj
[ 4%] Building CXX object source/matplot/CMakeFiles/matplot.dir/freestanding/axes_functions.cpp.obj
[ 4%] Building CXX object source/matplot/CMakeFiles/matplot.dir/freestanding/histcounts.cpp.obj
[ 4%] Linking CXX static library libmatplot.a
[ 4%] Built target matplot
[ 4%] Building CXX object test/generate_examples/CMakeFiles/generate_examples.dir/main.cpp.obj
[ 4%] Linking CXX executable generate_examples.exe
[ 4%] Built target generate_examples
[ 4%] Building CXX object examples/line_plot/plot/CMakeFiles/example_plot_1.dir/plot_1.cpp.obj
[ 4%] Linking CXX executable example_plot_1.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../../../source/matplot/libmatplot.a(gnuplot.cpp.obj):gnuplot.cpp:(.text+0x506d): undefined reference to `__imp__dupenv_s'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [examples\line_plot\plot\CMakeFiles\example_plot_1.dir\build.make:101: examples/line_plot/plot/example_plot_1.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:4006: examples/line_plot/plot/CMakeFiles/example_plot_1.dir/all] Error 2
mingw32-make: *** [Makefile:165: all] Error 2
为什么会发生这种情况,如何解决?
答: 暂无答案
评论