简体   繁体   中英

Create one .so file from code in two sub-directories

I need to create a .so file on Linux Ubuntu 13.10 so I could wrap with Python (but I am pretty new to cmake).

I have in my directory wrap /

map.h
map.cpp

/noise 
  /include
  /src

/noiseutils
  noiseutils.h
  noiseutils.cpp

noise is a directory with include and src directories in and noiseutils has noiseutils.h and noiseutils.cpp files inside.

Can anyone help me to create a .so file with cmake — I am very new to C++?

You will need to use the add_library command in your CMakeLists.txt configuration file. Here is the current command reference: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library

Notice the second option after the library name can be 'SHARED', giving your .so file on Linux.

The directory layouts of your sources is not important; you just need to provide the relative path to the .cpp file from the CMakeLists.txt (eg, noise/src/noise.cpp). And also make sure any directories containing .h files are included using the include_directories command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM