Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom library addition in visual studio code

I am making a static cpp libray with extension .h and I have written source code for the same in a different file with .cpp extension. Now I want to make a test script that will include the custom library that I just created. When I include this libary using #include<mylibrary.h>and try to run this test file, I get an error saying No such file or directory compilation terminated.

I know that I am getting this error because nowhere I have specified the path for same for the complier to look for this file as I used to do in Visual Studio environment. How to do the same in Visual Studio Code?

like image 957
skii Avatar asked Oct 25 '25 20:10

skii


1 Answers

The location of your .h file needs to be either in your compiler libraries folders or in the folder where you execute g++/clang++ or whatever compiler you use.

These are the default search-paths but you can add additional ones by adding the flag
-I path/to/folder in your tasks.json (or makefile if you are using one).

like image 55
Gmork Avatar answered Oct 28 '25 10:10

Gmork