I'm trying to get a Boost Unit Test program to run in VSCode, but I'm having trouble linking the library.
I've written a simple unit test setup with two classes, Boost Test, and FakeIt mocking framework, and easily verified that it works in VS2017. The motivation was to make it work in VSCode eventually though. When I build the project, it fails to find the boost test files. I tried a few different include options; absolutely path, relative path, and with environment variables (as seen in c_cpp_properties.json below).
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "g++ -g -Wall main.cpp -L/c:/boost/lib64-msvc-14.1 -llibboost_unit_test_framework-vc141-mt-gd-x64-1_69",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
"preLaunchTask": "echo",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${env:BOOST_ROOT}",
"${env:FAKEIT}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++}"
]
}
}
],
"version": 4
}
What I get is
Executing task: g++ -g main.cpp <
main.cpp:3:10: fatal error: boost/test/unit_test.hpp: No such file or directory
#include <boost/test/unit_test.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
The terminal process terminated with exit code: 1
Have I set up my build files incorrectly? Being used to VS2017, I'm fairly new to manually writing the build files, but I did make a working Hello World program in VSCode Cpp, so it's not like the compiler isn't working. Hope someone can help, I can provide the cpp/h files if requested, but it seems unnecessary given that I know it works in VS2017.
Edit1: I can even right click the Boost and FakeIt includes and "Go to Definition", and it opens the files, but when I try to build it says it can't...?!
Edit2: After some searching for makefile compiler commands, I updated the command to
g++ -g -Wall main.cpp -L/c:/boost/lib64-msvc-14.1
-llibboost_unit_test_framework-vc141-mt-gd-x64-1_69
, trying to tell the compiler to link the library (both .lib and .dll files are present in that folder) but it didn't change anything.
Cheers, Tachyon