These errors are not related to cmake, but to intellisense. If the compilation gets through, then you can filter those errors out. They are due to the fact that the auto completion plugin was not able to find all the include files it needs. Again, you either specify in the config files the directory where you created the view, or filter these errors out. 

Luca

Il giorno 23 apr 2023, alle ore 18:15, Vinayak Vijay <vinayak....@gmail.com> ha scritto:

Hi, thank you for your message. This has indeed allowed me to run dealii from any terminal without loading spack every time. However, the following error in vscode persists:

<Screenshot from 2023-04-23 17-14-25.png>


How to fix this now?

Thanks
Vinayak
On Sunday, April 23, 2023 at 3:00:53 PM UTC+2 luca....@gmail.com wrote:
An easy way (but it may slow down the startup of your bash terminals) would be to directly add to your .bashrc

spack load dealii

My preferred solution, instead, is to do the following: I create a `spack view` of all packages I need (i.e., just symbolic links to libraries and exectuable), using this command:

spack view -d yes add -i /some/path/to/an/empty/directory/of/your/choice/ dealii mpich (or openmpi, if that’s what’s installed) cmake ninja (gmsh, numdiff, etc.)

-d yes: add dependencies
-i: ignore errors

Then, in my bashrc, I add

export CMAKE_PREFIX_PATH=/some/path/to/a/directory/of/your/choice/
export PATH=/some/path/to/a/directory/of/your/choice/bin:$PATH

This makes sure that cmake sees everything, without having to load dealii explicitly with spack (which may take time, if you do it at every startup).

L.


> On 23 Apr 2023, at 12:50, Vinayak Vijay <vinay...@gmail.com> wrote:
>
> I get the error when i try to use "make". I am able to build using vscode now though.
>
> On Sunday, April 23, 2023 at 11:47:50 AM UTC+2 Vinayak Vijay wrote:
> I have added the DEAL_II_DIR variable in the cmake section of vscode as follows:
>
> Also, i have added the following lines to the .bashrc file for setting up the environment:
>
> export SPACK_ROOT=/home/vinayak/spack
> export PATH="$SPACK_ROOT/bin:$PATH"
>
> MODULES_HOME=$(spack location -i environment-modules)
> source ${MODULES_HOME}/init/bash
> . $SPACK_ROOT/share/spack/setup-env.sh
>
> Now I get a different error:
> `
> cannot open source file "mpi.h" (dependency of "deal.II/grid/tria.h")
> `
> And i am still not able to use dealii upon terminal launch without using "spack load dealii". Not sure what more changes i need to make to the vscode setting to make this work. Can you point me to it?
>
> Thanks
> Vinayak
> On Sunday, April 23, 2023 at 11:02:53 AM UTC+2 luca....@gmail.com wrote:
> Vscode does not call “spack load dealii “ by itself. If you want to be able to compile with vscode , you have two options: you instruct it where it can find dealii (setting variables in the cmake section of vscode settings) or adding the relevant variables to your shell initialization files. If you open a new terminal and you are able to compile deal tutorials without calling any additional commands, then vscode will work.
>
> Luca
>
>> Il giorno 23 apr 2023, alle ore 11:35, Vinayak Vijay <vinay...@gmail.com> ha scritto:
>>
>> 
>> "Do you have the cmake extension installed in vscode?" - Yes
>>
>> The thing is that i have installed dealii using spack. So everything works smoothly if i just try to build from the terminal but not when i try to build using vscode cmake extension. I think VSCode (or vscode cmake extension) is not able to recognize the environment variable DEAL_II_DIR even when "spack load dealii" command is made from the vscode terminal.
>>
>> Vinayak
>>
>> On Saturday, April 22, 2023 at 7:50:23 PM UTC+2 luca....@gmail.com wrote:
>> Cmake does not know where to find a correct version of deal.ii.
>>
>> Are you trying to compile an example from the GitHub repository with an earlier release of deal.ii? If that’s the case, try removing the version from the find statement in the CMakeLists.txt. Otherwise you will have to instruct vscode where your library is installed. You can initiate cmake from the command line in the build directory manually, specifying the env variable DEAL_II_DIR. When a cmake cache is present, vscode uses it, and you may be able to get through.
>>
>> Luca
>>
>>> Il giorno 22 apr 2023, alle ore 20:18, Abbas <abbas.b...@gmail.com> ha scritto:
>>>
>>> Do you have the cmake extension installed in vscode?
>>> If not give it a try
>>>
>>> Abbas
>>>
>>> On Saturday, April 22, 2023 at 1:44:41 PM UTC+2 vinay...@gmail.com wrote:
>>> Hi,
>>>
>>> I am trying to build step-1 using cmake on vscode. But vscode throws me this error:
>>>
>>> `
>>> CMake Error at CMakeLists.txt:30 (message):
>>>
>>> *** Could not locate a (sufficiently recent) version of deal.II. ***
>>>
>>>
>>>
>>> You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake
>>>
>>> or set an environment variable "DEAL_II_DIR" that contains this path.
>>>
>>> `
>>> I have installed dealii using spack. I am able to build using the terminal though. What changes do i need to make for building using vscode?
>>>
>>> Thanks
>>> Vinayak
>>>
>>>
>>> --
>>> The deal.II project is located at http://www.dealii.org/
>>> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/ade9af1e-1787-4840-b9db-c49e45dc6cc3n%40googlegroups.com.
>>
>> --
>> The deal.II project is located at http://www.dealii.org/
>> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/70f20c32-2221-4195-9e1f-cb23c10507e1n%40googlegroups.com.
>
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/d6056409-ef5a-4ab5-abd5-53bf904a4d91n%40googlegroups.com.

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/b74d4300-9759-43dd-9901-3762fac19bd5n%40googlegroups.com.
<Screenshot from 2023-04-23 17-14-25.png>

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/54255857-B0CD-4563-B8C1-23F5EE83A28D%40gmail.com.

Reply via email to