I have a program that I am trying to run in the Visual Studio Code debugger that uses fftw functions. It compiles with the command
g++ dimer.cpp -std=c++11 -lfftw3
on the terminal on my computer without complaining about undefined references. However, after generating a launch.json file, my program complains about fftw library functions and about the -std=c++14
compiler flag.
I believe that it needs just the extra flags of -std=c++11
and -lfftw3
for the debugger in Visual Studio Code to work. I am using Microsoft's C/C++ extension and the Code Runner extension.
I am trying to transform a Mathematica document of code into c++.
Below are the errors I get from the output.
Executing task: /usr/bin/g++ -g /home/msammartino/Documents/twochain/dimer.cpp -o /home/msammartino/Documents/twochain/dimer <
In file included from /usr/include/armadillo:54:0,
from /home/msammartino/Documents/twochain/dimer.cpp:6:
/usr/include/armadillo_bits/compiler_setup.hpp:530:108: note: #pragma message: NOTE: suggest to enable C++14 mode for faster code; add -std=c++14 to compiler flags
#pragma message ("NOTE: suggest to enable C++14 mode for faster code; add -std=c++14 to compiler flags")
^
/tmp/ccgb7Xsv.o: In function `r2r_dsine_fftw_forward_dimer(int, double*, double*, Eigen::Matrix<double, 2, 2, 0, 2, 2> (&) [2048], Eigen::Matrix<double, 2, 2, 0, 2, 2> (&) [2048])':
/home/msammartino/Documents/twochain/dimer.cpp:99: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:100: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:101: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:102: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:103: undefined reference to `fftw_execute'
/home/msammartino/Documents/twochain/dimer.cpp:104: undefined reference to `fftw_execute'
/home/msammartino/Documents/twochain/dimer.cpp:105: undefined reference to `fftw_execute'
/home/msammartino/Documents/twochain/dimer.cpp:106: undefined reference to `fftw_execute'
/tmp/ccgb7Xsv.o: In function `r2r_dsine_fftw_backward_dimer(int, double*, double*, Eigen::Matrix<double, 2, 2, 0, 2, 2> (&) [2048], Eigen::Matrix<double, 2, 2, 0, 2, 2> (&) [2048])':
/home/msammartino/Documents/twochain/dimer.cpp:166: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:167: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:168: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:169: undefined reference to `fftw_plan_r2r_1d'
/home/msammartino/Documents/twochain/dimer.cpp:170: undefined reference to `fftw_execute'
/home/msammartino/Documents/twochain/dimer.cpp:171: undefined reference to `fftw_execute'
/home/msammartino/Documents/twochain/dimer.cpp:172: undefined reference to `fftw_execute'
/home/msammartino/Documents/twochain/dimer.cpp:173: undefined reference to `fftw_execute'
collect2: error: ld returned 1 exit status
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
Please let me know about any problems with the way I have asked this question.
See Question&Answers more detail:os