[英]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). 我需要在Linux Ubuntu 13.10上创建一个
.so
文件,以便可以用Python包装(但是我对cmake还是很陌生的)。
I have in my directory wrap
/ 我的目录中
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. noise
是一个目录, include
和src
在目录和noiseutils
具有noiseutils.h
和noiseutils.cpp
内的文件。
Can anyone help me to create a .so
file with cmake — I am very new to C++? 谁能帮我用cmake创建
.so
文件-我对C ++很陌生?
You will need to use the add_library
command in your CMakeLists.txt configuration file. 您将需要在CMakeLists.txt配置文件中使用
add_library
命令。 Here is the current command reference: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library 这是当前的命令参考: 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. 请注意,库名称可以为“ SHARED”之后的第二个选项,在Linux上为您提供.so文件。
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).
您只需要提供CMakeLists.txt中.cpp文件的相对路径(例如,noise / src / noise.cpp)。 And also make sure any directories containing .h files are included using the
include_directories
command. 并且还要使用
include_directories
命令确保包含任何包含.h文件的目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.