# Stored procedure compilation without main function

**URL:** https://discourse.cmake.org/t/stored-procedure-compilation-without-main-function/10150
**Category:** Usage
**Tags:** os:linux
**Created:** [February 21, 2024, 3:21pm UTC](https://discourse.cmake.org/t/stored-procedure-compilation-without-main-function/10150 "2024-02-21T15:21:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Vekleon](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/46a35a/32.png) [@Vekleon](https://discourse.cmake.org/u/Vekleon)
#### Post date: [February 21, 2024, 3:21pm UTC](https://discourse.cmake.org/t/stored-procedure-compilation-without-main-function/10150/1 "2024-02-21T15:21:09Z")

</div>

I’m trying to make a stored procedure for a database with the use of a large library (hence the need for cmake). The issue is that I’m hitting a `undefined reference to 'main'` error.

My stored procedures don’t need a main function but it seems like cmake is expecting one. Is there a way to build the binary without having to define a main function? I saw that there was a work around to define some dummy entry point in a separate file, but I’m wondering if there is a way around this?

---

<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: [February 27, 2024, 1:54pm UTC](https://discourse.cmake.org/t/stored-procedure-compilation-without-main-function/10150/2 "2024-02-27T13:54:39Z")

</div>

Usually there are linker flags to do this; CMake has no abstraction for it though. I suspect you probably want module libraries (`add_library(MODULE)`) rather than executables (`add_executable()`) though.

---

<div class="post-metadata">

### Author: ![Vekleon](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/46a35a/32.png) [@Vekleon](https://discourse.cmake.org/u/Vekleon)
#### Post date: [February 28, 2024, 8:38pm UTC](https://discourse.cmake.org/t/stored-procedure-compilation-without-main-function/10150/3 "2024-02-28T20:38:02Z")

</div>

Yes I have moved to using add\_library now and it seemed to help me move forward to what it is that I am trying to accomplish, thanks.
