'Code builds and runs, but shows red squiggles. using CMAKE in vs code, C++
i have just started to use vscode and CMAKE. and to learn this i have made a simple project in this regard
My code builds and runs, however the red squiggles does not seem to go away. what should i do, is it still a stable program??
project structure:
|CMakeLists.txt
|App
+---CMakeLists.txt
+---main.cpp
|Source_DIR
+---CMakeLists.txt
+---src
------+---helloworld.cpp
+---include
------+---helloworld.h
toplevel cmakelists.txt:
cmake_minimum_required(VERSION 3.15...3.18)
project(Project_RetroTron VERSION 1.0.0)
add_subdirectory(source_DIR)
add_subdirectory(app)
source_DIR/cmakelists.txt:
add_library(hello_world
src/helloworld.cpp)
target_include_directories(hello_world PUBLIC PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
source_DIR/include/helloworld.h
#ifndef HELLOWORLD_H
#define HELLOWORLD_H
class helloWorld
{
public:
helloWorld();
};
#endif
source_DIR/src/helloworld.cpp
#include <iostream>
#include "helloworld.h"
helloWorld::helloWorld()
{
std::cout <<"hello my man" << std::endl;
}
app/CMakeLists.txt
add_executable(helloworldMain main.cpp)
target_link_libraries(helloworldMain PRIVATE hello_world)
app/main.cpp
#include <iostream>
#include <stdio.h>
#include "helloworld.h"
int main()
{
helloWorld heya;
}
i also use cmake-tools which generates this .vscode folder with a settings.JSON file on the top level of the hiearchy:
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
used vscode on windows. the build have been erased and rerun so it does not have any old files to refer to.
why do i still have an error!!!
this is the result of a build and run, adn as you can see it runs fine:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

