Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit 2afc53d

Browse files
author
Matus Novak
committed
Updated documentation and fixed CMAKE_BUILD_TYPE
1 parent 717fa9f commit 2afc53d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ project (PythonEmbeddedExample)
66
set (CMAKE_CXX_STANDARD 11)
77

88
# Specify build type
9-
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Select build type")
9+
if(NOT CMAKE_BUILD_TYPE)
10+
set(CMAKE_BUILD_TYPE "Debug")
11+
endif()
1012
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
1113

1214
if (CMAKE_BUILD_TYPE MATCHES "Debug")

README.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Python Embedded Example Project
22

3-
This is an example project using mebedded python 3.8 (cpython) in C++ console application using CMake. This example project also contains pybind11 library for easy binding between C++ and python.
3+
This is an example project using mebedded **[python 3.8](https://github.com/python/cpython)** in C++ console application using CMake. This example project also contains **[pybind11](https://github.com/pybind/pybind11)** library for easy binding between C++ and python.
44

55
Tested on Windows 10 with Visual Studio 2013, 2015, and 2017 (both x86 and x64). Also tested on Ubuntu with GCC (x64).
66

@@ -37,13 +37,13 @@ Visual Studio 2013 (or newer) or Linux with GCC. MinGW is sadly not supported, a
3737

3838
## Download
3939

40-
Don't forget to initialise and update the submodules!
40+
Don't forget to initialise and update the submodules! The cpython is +200MB so it may take some time to during `git submodule update`.
4141

4242
```
4343
git clone https://github.com/matusnovak/python-embedded-example-project
4444
cd python-embedded-example-project
45-
git submodile init
46-
git submodule update
45+
git submodule init
46+
git submodule update --progress
4747
```
4848

4949
## Build using Visual Studio on Windows
@@ -83,6 +83,10 @@ make
8383

8484
The `PythonEmbeddedExample` executable will be generated.
8585

86+
## Changing python version
87+
88+
At the time of the creation of this example, Python 3.8 was just released. The cpython submodule is frozen to commit `491bbedc209fea314a04cb3015da68fb0aa63238`. If you want to change python version, change the `branch` in `.gitmodules` to `branch = 2.7` or any other version. See available branches at: <https://github.com/python/cpython>
89+
8690
## Example output
8791

8892
Example output of the `PythonEmbeddedExample` executable.
@@ -92,4 +96,10 @@ Python PATH set to: C:\Users\matus\Documents\cpp\python-embedded-example-project
9296
Importing module...Initializing class...
9397
Example constructor with msg: Hello World
9498
Got msg back on C++ side: Hello World
95-
```
99+
```
100+
101+
## fatal error LNK1104: cannot open file 'python38_d.lib'
102+
103+
This happens when you run cmake with `-DCMAKE_BUILD_TYPE=MinSizeRel` and you are compiling the solution in Visual Studio as Debug. Simply, in Visual Studio, change the configuration to the one used in `CMAKE_BUILD_TYPE`.
104+
105+
This happens because the cpython has been built via `CMAKE_BUILD_TYPE` but your Visual Studio is looking for a debug version of the python library (or the other way around).

0 commit comments

Comments
 (0)