# Can't build 32bit DLL files with Cmake

**URL:** <https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535>\
**Category:** Code\
**Created:** [April 25, 2022, 10:00pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535 "2022-04-25T22:00:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeVaughn\_BB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/b38774/32.png) [@DeVaughn\_BB](https://discourse.cmake.org/u/DeVaughn_BB)\
**Post date:** [April 25, 2022, 10:00pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535/1 "2022-04-25T22:00:22Z")

</div>

Hi currently I am attempting to build 32bit DLL files using cmake to execute a program however when I execute I only get a new solution file not new 32bit DLL files

cmake command ran in command prompt: cmake -H"OptickCore.dll" -B"build\cmake" -G “Visual Studio 9 2008”

## Below is my CMakeLists.txt file CMakeLists.txt :

* * *

## cmake\_minimum\_required(VERSION 2.6) add\_library(mylib SHARED DarkGDK\_MovingBall.cpp) set\_target\_properties(mylib PROPERTIES COMPILE\_FLAGS “-m32” LINK\_FLAGS “-m32”)

Why am I getting only a new solution file instead of a new DLL file?

---

<div class="post-metadata">

**Author:** ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)\
**Post date:** [April 25, 2022, 10:22pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535/2 "2022-04-25T22:22:00Z")

</div>

The default architecture for Visual Studio generators on Win64 systems is x64. To build 32bit DLL files you need to add `-A Win32` to your CMake command line.

---

<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:** [April 25, 2022, 10:23pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535/3 "2022-04-25T22:23:26Z")

</div>

> [@vre](#):
>
> The default architecture for Visual Studio generators on Win64 systems is x64

I don’t believe this is true for older VS generators (including 2008).

> [@DeVaughn\_BB](#):
>
> Why am I getting only a new solution file instead of a new DLL file?

CMake only generates the project to make the library. You can use `cmake --build . --config Release` to build the project (replace `Release` with `Debug` if you want such a build).

---

<div class="post-metadata">

**Author:** ![vre](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@vre](https://discourse.cmake.org/u/vre)\
**Post date:** [April 25, 2022, 10:25pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535/4 "2022-04-25T22:25:16Z")

</div>

You are right. I mixed that up with newer Visual Studio generators.

---

<div class="post-metadata">

**Author:** ![DeVaughn\_BB](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/b38774/32.png) [@DeVaughn\_BB](https://discourse.cmake.org/u/DeVaughn_BB)\
**Post date:** [April 25, 2022, 10:47pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535/5 "2022-04-25T22:47:16Z")

</div>

So how do I use the project made by cmake to create a new library DLL out of my “OptickCore.dll” after the project is made?

---

<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:** [April 25, 2022, 11:20pm UTC](https://discourse.cmake.org/t/cant-build-32bit-dll-files-with-cmake/5535/6 "2022-04-25T23:20:32Z")

</div>

The `cmake --build .` command I gave above should do.
