# How to create stripped dll

**URL:** <https://discourse.cmake.org/t/how-to-create-stripped-dll/8347>\
**Category:** Code\
**Tags:** os:windows, gen:makefiles\
**Created:** [June 19, 2023, 3:45am UTC](https://discourse.cmake.org/t/how-to-create-stripped-dll/8347 "2023-06-19T03:45:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akash\_01](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/b38774/32.png) [@Akash\_01](https://discourse.cmake.org/u/Akash_01)\
**Post date:** [June 19, 2023, 3:45am UTC](https://discourse.cmake.org/t/how-to-create-stripped-dll/8347/1 "2023-06-19T03:45:34Z")

</div>

Hi,  
I was trying to migrate my environment to CMAKE to use GCC compiler with VS.  
Previously I are using make script.  
Can any one support me on how to generate the below make command in the CMAKE script. In the below make command we are generating the .a .dll and stripped .a and .dll

```auto
type $(OUTDIR)/$(PROJ).dll: $(OBJECTS)
	@$(ECHO) Linking and locating to $(PROJ).dll
	@$(BINDIR)/gcc -shared -Wl,-Map=$(OUTDIR)/$(PROJ).map -o$(OUTDIR)/$(PROJ).dll $(OPT_LC) @objects.txt
	@$(BINDIR)/strip -s -o $(OUTDIR)/$(PROJ)_stripped.dll $(OUTDIR)/$(PROJ).dll

$(OUTDIR)/$(PROJ).a: $(OBJECTS)
	@$(ECHO) Creating $(PROJ).a
	@$(shell $(RM) -f $(OUTDIR)/$(PROJ).a)
	@$(BINDIR)/ar r $(OUTDIR)/$(PROJ).a @objects.txt
	@$(BINDIR)/strip -g -X -x -o $(OUTDIR)/$(PROJ)_stripped.a $(OUTDIR)/$(PROJ).aor paste code here

```

---

<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:** [June 19, 2023, 2:22pm UTC](https://discourse.cmake.org/t/how-to-create-stripped-dll/8347/2 "2023-06-19T14:22:57Z")

</div>

CMake tends to strip on the `install` step rather than right after linking. However, you can use `add_custom_command(POST_LINK)` to do post-link steps like this (though I don’t think CMake exposes any “how to strip a library” abstraction to make it really easy).

---

<div class="post-metadata">

**Author:** ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Post date:** [June 19, 2023, 8:39pm UTC](https://discourse.cmake.org/t/how-to-create-stripped-dll/8347/3 "2023-06-19T20:39:43Z")

</div>

[cmake --install --strip](https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project) example

```sh
cmake -S . -B build/ ...

cmake --build build/ ...

# Install binaries
cmake --install build/ --prefix build/unstripped ...

# Install stripped binaries
cmake --install build/ --prefix build/stripped --strip... 

```

I personally like the way CMake handles this. Since it gives more flexibility via the CLI to users.

---

<div class="post-metadata">

**Author:** ![Akash\_01](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/b38774/32.png) [@Akash\_01](https://discourse.cmake.org/u/Akash_01)\
**Post date:** [June 20, 2023, 3:50am UTC](https://discourse.cmake.org/t/how-to-create-stripped-dll/8347/4 "2023-06-20T03:50:08Z")

</div>

I was using Visual Studio is it possible to to install it in VS.?  
If it is a CLI I hope that would be straightforward. I am not sure weather it comes by default with VS or we need to install it manually

---

<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:** [June 20, 2023, 2:22pm UTC](https://discourse.cmake.org/t/how-to-create-stripped-dll/8347/5 "2023-06-20T14:22:46Z")

</div>

I suppose an `install/strip` target in VS might make sense… Might be worth [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) if the functionality isn’t hiding somewhere already.
