Reputation: 2001
I've installed SFML but Visual Studio Code can't find the library. I am really new to Ubuntu and also pretty new to C++.
How can I get my IDE to recognize the library?
Here is what "libsfml-graphics-d.so
" displays when entered into the terminal.
libsfml-window-d.so.2.5 (libc6,x86-64) => /usr/local/lib/libsfml-window-d.so.2.5
libsfml-window-d.so (libc6,x86-64) => /usr/local/lib/libsfml-window-d.so
libsfml-system-d.so.2.5 (libc6,x86-64) => /usr/local/lib/libsfml-system-d.so.2.5
libsfml-system-d.so (libc6,x86-64) => /usr/local/lib/libsfml-system-d.so
libsfml-network-d.so.2.5 (libc6,x86-64) => /usr/local/lib/libsfml-network-d.so.2.5
libsfml-network-d.so (libc6,x86-64) => /usr/local/lib/libsfml-network-d.so
libsfml-graphics-d.so.2.5 (libc6,x86-64) => /usr/local/lib/libsfml-graphics-d.so.2.5
libsfml-graphics-d.so (libc6,x86-64) => /usr/local/lib/libsfml-graphics-d.so
libsfml-audio-d.so.2.5 (libc6,x86-64) => /usr/local/lib/libsfml-audio-d.so.2.5
libsfml-audio-d.so (libc6,x86-64) => /usr/local/lib/libsfml-audio-d.so
These are my User Settings in Visual Studio Code:
{
"editor.detectIndentation": false,
"editor.tabSize": 3,
"editor.insertSpaces": true,
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"window.zoomLevel": 1,
"editor.rulers": [80,120],
"clang.cxxflags": ["/usr/local/lib/"],
}
When my mouse hovers over my C++ code, "#include <libsfml-graphics-d.so>
" this text is displayed:
#include errors detected. Please update your includePath.
IntelliSense features for this translation unit (/home/userName/Desktop/Temp_Towers_Of_Babel/World_Generation/Main.cpp) will be provided by the Tag Parser.
Cannot open source file "libsfml-graphics-d.so"
'libsfml-graphics-d.so' file not found
Upvotes: 2
Views: 3123
Reputation: 871
If you would like to include e.g SFML graphics why don't you try this way?
#include <SFML/Graphics.hpp>
On the other hand, I recommend you to install "c/c++" plugin if you would like to work with C++ in VS Code. You can find it on the marketplace with this search term c/c++
.
vscode-cpptools
If you can compile the example code from here with g++ that is a good point.
I think CMake also help me a lot in connection with proper configuration.
e.g. This is a simple CMakeLists.txt file. Here you can read the whole article.
cmake_minimum_required(VERSION 3.1)
project(SFMLTest)
## If you want to link SFML statically
# set(SFML_STATIC_LIBRARIES TRUE)
## In most cases better set in the CMake cache
# set(SFML_DIR "<sfml root prefix>/lib/cmake/SFML")
find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
add_executable(SFMLTest main.cpp)
target_link_libraries(SFMLTest sfml-graphics sfml-audio)
whereis SFML
command may help you to find the <sfml root prefix>
part of this line # set(SFML_DIR "<sfml root prefix>/lib/cmake/SFML")
CMakeList.txt
file in the project root folderapt install cmake
commandmkdir build
cd build
cmake ..
make
after this step you will get an executable named SFMLTest
Upvotes: 1