# Loading .SO file using CMAKE

**URL:** https://discourse.cmake.org/t/loading-so-file-using-cmake/7252
**Category:** Code
**Tags:** os:linux
**Created:** [January 15, 2023, 12:03pm UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252 "2023-01-15T12:03:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jubin2607](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jubin2607/32/3077_2.png) [@Jubin2607](https://discourse.cmake.org/u/Jubin2607)
#### Post date: [January 15, 2023, 12:03pm UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252/1 "2023-01-15T12:03:11Z")

</div>

I am facing an issue while loading a .SO file using cmake  
The error which I am getting is “undefined reference to” some function which I am accessing while building  
Compilation of the code is proper.

---

<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: [January 17, 2023, 12:46am UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252/2 "2023-01-17T00:46:01Z")

</div>

There is not enough information here to give any useful advice. Are you trying to have CMake load a library? Where is the `.so` being loaded coming from? What is trying to load it? What symbol is missing?

---

<div class="post-metadata">

### Author: ![Jubin2607](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jubin2607/32/3077_2.png) [@Jubin2607](https://discourse.cmake.org/u/Jubin2607)
#### Post date: [January 17, 2023, 7:22am UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252/3 "2023-01-17T07:22:14Z")

</div>

Yes I am trying to use CMAKE to load a .so file, So when I loading and accessing functions from the .so file I am getting “undefined reference to” a function within .so file as an error.

---

<div class="post-metadata">

### Author: ![xhustango](https://discourse.cmake.org/user_avatar/discourse.cmake.org/xhustango/32/1614_2.png) [@xhustango](https://discourse.cmake.org/u/xhustango)
#### Post date: [January 17, 2023, 9:25am UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252/4 "2023-01-17T09:25:08Z")

</div>

Do you have the .SO placed in the same folder as the executable?

---

<div class="post-metadata">

### Author: ![Jubin2607](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jubin2607/32/3077_2.png) [@Jubin2607](https://discourse.cmake.org/u/Jubin2607)
#### Post date: [January 17, 2023, 11:21am UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252/5 "2023-01-17T11:21:17Z")

</div>

SO will be part of one folder, the include files of SO will be another folder, the executable will be third folder.  
I am building the cmake in Visual studio for a cross platform build on linux.

---

<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: [January 17, 2023, 4:55pm UTC](https://discourse.cmake.org/t/loading-so-file-using-cmake/7252/6 "2023-01-17T16:55:33Z")

</div>

CMake does not “load” `.so` files except via a heavily deprecated and discouraged API. What is the link line for this `.so` target? What symbol(s) are missing?
