# CMake Tutorial Step5: install()

**URL:** https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554
**Category:** Usage
**Tags:** os:windows
**Created:** [July 20, 2023, 1:25am UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554 "2023-07-20T01:25:07Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_Gaidachev](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex_gaidachev/32/3626_2.png) [@Alex\_Gaidachev](https://discourse.cmake.org/u/Alex_Gaidachev)
#### Post date: [July 20, 2023, 1:25am UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/1 "2023-07-20T01:25:07Z")

</div>

Hi All, signed up and creating this post to see what you, the community thinks of this issue and what my next steps are in resolving it, (I used PowerShell command Prompt):

PS C:\Work\Cmake\project5\build\> cmake …\build  
– Configuring done (0.0s)  
– Generating done (0.2s)  
– Build files have been written to: C:/Work/Cmake/project5/build  
PS C:\Work\Cmake\project5\build\> cmake --install .  
– Install configuration: “Release”  
CMake Error at MathFunctions/cmake\_install.cmake:39 (file):  
file INSTALL cannot find  
“C:/Work/Cmake/project5/build/MathFunctions/Release/MathFunctions.lib”: No  
error.  
Call Stack (most recent call first):  
cmake\_install.cmake:37 (include)

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [July 20, 2023, 9:17am UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/2 "2023-07-20T09:17:29Z")

</div>

AFAIK it’s a known limitation, that “install” does not depend on “all”. One has to do the build first.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 20, 2023, 5:16pm UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/3 "2023-07-20T17:16:01Z")

</div>

`install` does depend on `all`; `install/fast` does not. I suspect the problem here is that `MathFunctions` doesn’t export symbols, so there’s no `.lib` to install.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 20, 2023, 5:16pm UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/4 "2023-07-20T17:16:35Z")

</div>

Cc: @betsy.mcphail since this is a tutorial thing.

---

<div class="post-metadata">

### Author: ![betsy.mcphail](https://discourse.cmake.org/user_avatar/discourse.cmake.org/betsy.mcphail/32/299_2.png) [@betsy.mcphail](https://discourse.cmake.org/u/betsy.mcphail)
#### Post date: [July 20, 2023, 5:34pm UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/5 "2023-07-20T17:34:40Z")

</div>

Does `C:/Work/Cmake/project5/build/MathFunctions/Release/MathFunctions.lib` exist? The output does seem to suggest that it hasn’t been built yet. Does the command `cmake --build . --target install` work?

---

<div class="post-metadata">

### Author: ![Alex\_Gaidachev](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex_gaidachev/32/3626_2.png) [@Alex\_Gaidachev](https://discourse.cmake.org/u/Alex_Gaidachev)
#### Post date: [July 22, 2023, 12:23am UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/6 "2023-07-22T00:23:22Z")

</div>

Hi! Thank you all for your support,  
@betsy.mcphail , I’ve ran your command in my PowerShell Administrator, and I’ve gotten a whole bunch of error outputs:

```auto
PS C:\Work\Cmake\project5\build> PS C:\Work\Cmake\project5\build> cmake --build . --target install
Get-Process : A positional parameter cannot be found that accepts argument 'cmake'.
At line:1 char:1
+ PS C:\Work\Cmake\project5\build> cmake --build . --target install
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Get-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetProcessCommand

PS C:\Work\Cmake\project5\build> MSBuild version 17.6.3+07e294721 for .NET Framework
MSBuild : The term 'MSBuild' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MSBuild version 17.6.3+07e294721 for .NET Framework
+ ~~~~~~~
    + CategoryInfo : ObjectNotFound: (MSBuild:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>
PS C:\Work\Cmake\project5\build> SqrtLibrary.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\SqrtLibrary.lib
SqrtLibrary.vcxproj : The term 'SqrtLibrary.vcxproj' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:3
+ SqrtLibrary.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\D ...
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (SqrtLibrary.vcxproj:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> MathFunctions.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\MathFunctions.lib
MathFunctions.vcxproj : The term 'MathFunctions.vcxproj' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:3
+ MathFunctions.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions ...
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (MathFunctions.vcxproj:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> Tutorial.vcxproj -> C:\Work\Cmake\project5\build\Debug\Tutorial.exe
Tutorial.vcxproj : The term 'Tutorial.vcxproj' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:3
+ Tutorial.vcxproj -> C:\Work\Cmake\project5\build\Debug\Tutorial.exe
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Tutorial.vcxproj:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Suggestion [3,General]: The command Tutorial.vcxproj was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Tutorial.vcxproj". See "get-help about_Command_Precedence" for more details.
PS C:\Work\Cmake\project5\build> -- Install configuration: "Debug"
At line:1 char:5
+ -- Install configuration: "Debug"
+ ~
Missing expression after unary operator '--'.
At line:1 char:6
+ -- Install configuration: "Debug"
+ ~~~~~~~
Unexpected token 'Install' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

PS C:\Work\Cmake\project5\build> -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib
At line:1 char:5
+ -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.li ...
+ ~
Missing expression after unary operator '--'.
At line:1 char:6
+ -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.li ...
+ ~~~~~~~~~~~
Unexpected token 'Installing:' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

PS C:\Work\Cmake\project5\build> CMake Error at MathFunctions/cmake_install.cmake:37 (file):
file : The term 'file' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:56
+ CMake Error at MathFunctions/cmake_install.cmake:37 (file):
+ ~~~~
    + CategoryInfo : ObjectNotFound: (file:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> file INSTALL cannot copy file
file : The term 'file' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:5
+ file INSTALL cannot copy file
+ ~~~~
    + CategoryInfo : ObjectNotFound: (file:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> "C:/Work/Cmake/project5/build/MathFunctions/Debug/MathFunctions.lib" to
At line:1 char:74
+ ... :/Work/Cmake/project5/build/MathFunctions/Debug/MathFunctions.lib" to
+ ~~
Unexpected token 'to' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS C:\Work\Cmake\project5\build> "C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib": Permission denied.
At line:1 char:60
+ "C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib": Permissi ...
+ ~
Unexpected token ':' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS C:\Work\Cmake\project5\build> Call Stack (most recent call first):
most : The term 'most' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:15
+ Call Stack (most recent call first):
+ ~~~~
    + CategoryInfo : ObjectNotFound: (most:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> cmake_install.cmake:37 (include)
include : The term 'include' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:29
+ cmake_install.cmake:37 (include)
+ ~~~~~~~
    + CategoryInfo : ObjectNotFound: (include:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build>
PS C:\Work\Cmake\project5\build>
PS C:\Work\Cmake\project5\build> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Micro ...
+ ~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Work\Cmake\project5\build> rror MSB3073: The command "setlocal [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake [C:\Work\Cmake\project5\
>> build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :cmEnd [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :cmErrorLevel [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: exit /b %1 [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :cmDone [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Work\Cmake\project5\build\install.vcxproj]
>> C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(160,5): e
>> rror MSB3073: :VCEnd" exited with code 1. [C:\Work\Cmake\project5\build\install.vcxproj]
rror : The term 'rror' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ rror MSB3073: The command "setlocal [C:\Work\Cmake\project5\build\ins ...
+ ~~~~
    + CategoryInfo : ObjectNotFound: (rror:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

```

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [July 24, 2023, 9:51am UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/7 "2023-07-24T09:51:09Z")

</div>

@Alex_Gaidachev you’ve run this:

> [@Alex\_Gaidachev](#):
>
> `PS C:\Work\Cmake\project5\build> cmake --build . --target install`

but you were supposed to run

> [@betsy.mcphail](#):
>
> cmake --build . --target install

---

<div class="post-metadata">

### Author: ![Alex\_Gaidachev](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex_gaidachev/32/3626_2.png) [@Alex\_Gaidachev](https://discourse.cmake.org/u/Alex_Gaidachev)
#### Post date: [July 25, 2023, 6:33pm UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/8 "2023-07-25T18:33:26Z")

</div>

> [@betsy.mcphail](#):
>
> cmake --build . --target install

Sure, I ran your recommended line script:

```auto
PS C:\Work\Cmake\project5\build> cmake --build . --target install
MSBuild version 17.6.3+07e294721 for .NET Framework

  SqrtLibrary.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\SqrtLibrary.lib
  MathFunctions.vcxproj -> C:\Work\Cmake\project5\build\MathFunctions\Debug\MathFunctions.lib
  Tutorial.vcxproj -> C:\Work\Cmake\project5\build\Debug\Tutorial.exe
  -- Install configuration: "Debug"
  -- Installing: C:/Program Files (x86)/Tutorial/lib/MathFunctions.lib
  -- Installing: C:/Program Files (x86)/Tutorial/lib/SqrtLibrary.lib
  -- Installing: C:/Program Files (x86)/Tutorial/include/MathFunctions.h
  -- Installing: C:/Program Files (x86)/Tutorial/bin/Tutorial.exe
  -- Installing: C:/Program Files (x86)/Tutorial/include/TutorialConfig.h
PS C:\Work\Cmake\project5\build>

```

Which makes it so weird that it worked considering that my previous line was exactly like yours:

```auto
cmake --build . --target install

```

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 26, 2023, 12:24am UTC](https://discourse.cmake.org/t/cmake-tutorial-step5-install/8554/9 "2023-07-26T00:24:37Z")

</div>

Your previous line started with `PS C:\Work\Cmake\project5\build>` (i.e. you copy-and-pasted the command prompt as part of the command to execute).
