Невозможно открыть включить файл "python.h" в Windows при создании DLLC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Невозможно открыть включить файл "python.h" в Windows при создании DLL

Сообщение Anonymous »

I am creating a DLL that I'd like to use in other projects, but has a Python dependency (there is no getting around this; the CPP DLL must call a Python module).
Platform: Windows
IDE: Visual Studio
Use Vcpkg Manifest : yes
Target Triplet : "x64-windows-static-md"
Добавлен Python3 с помощью:

Код: Выделить всё

vcpkg add port python3
< /code>
Затем ran ​​< /p>
vcpkg install
< /code>
кажется установленным нормальным, потому что вывод: < /p>
warning: In the September 2023 release, the default triplet for vcpkg libraries changed from x86-windows to the detected host triplet (x64-windows). For the old behavior, add --triplet x86-windows .  To suppress this message, add --triplet x64-windows .
Detecting compiler hash for triplet x64-windows...
All requested packages are currently installed.
Total install time: 1.2 us
zeromq provides CMake targets:

# this is heuristically generated, and may not be correct
find_package(ZeroMQ CONFIG REQUIRED)
target_link_libraries(main PRIVATE libzmq libzmq-static)

zeromq provides pkg-config modules:

# 0MQ c++ library
libzmq

cppzmq provides CMake targets:

# this is heuristically generated, and may not be correct
find_package(cppzmq CONFIG REQUIRED)
target_link_libraries(main PRIVATE cppzmq cppzmq-static)

cppzmq provides pkg-config modules:

# C++ binding for libzmq
cppzmq

The package python3 is compatible with built-in CMake targets:

find_package(Python3 COMPONENTS Development REQUIRED)
target_link_libraries(main PRIVATE Python3::Python)

The package python3 provides a python interpreter that supports virtual environments:

>tools\python3\python.exe -m venv c:\path\to\venv
>set VIRTUAL_ENV=c:\path\to\venv
>set PATH=c:\path\to\venv\bin;%PATH%
>set PYTHONHOME=

See https://docs.python.org/3/library/venv.html for more details.
< /code>
Моя проблема возникает при строительстве: < /p>
Rebuild started at 12:27 AM...
1>------ Rebuild All started: Project: DLLTester, Configuration: Release x64 ------
2>------ Rebuild All started: Project: AsyncDLLMQL, Configuration: Release x64 ------
1>DLLTester.cpp
2>pch.cpp
1>LINK : fatal error LNK1181: cannot open input file 'AsyncDLLMQL.lib'
2>dllmain.cpp
2>mt5.cpp
2>utils.cpp
2>ZMQL.cpp
1>Done building project "DLLTester.vcxproj" -- FAILED.
2>D:\Redacted\Dev\AsyncDLLMQL\AsyncDLLMQL\mt5.cpp(3,10): error C1083: Cannot open include file: 'Python.h': No such file or directory
2>(compiling source file '/mt5.cpp')
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xutility(4537,18): warning C4244: '=': conversion from 'wchar_t' to 'char', possible loss of data
2>(compiling source file '/ZMQL.cpp')
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xutility(4537,18):
2>the template instantiation context (the oldest one first) is
2>D:\Redacted\Dev\AsyncDLLMQL\AsyncDLLMQL\ZMQL.cpp(47,16):
2>see reference to function template instantiation 'std::basic_string::basic_string(_Iter,_Iter,const _Alloc &)' being compiled
2>        with
2>        [
2>            _Elem=wchar_t,
2>            _Iter=std::_String_iterator,
2>            _Alloc=std::allocator
2>        ]
2>D:\Redacted\Dev\AsyncDLLMQL\AsyncDLLMQL\ZMQL.cpp(47,16):
2>see the first reference to 'std::basic_string::basic_string' in 'init_zmq'
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xstring(2600,17):
2>see reference to function template instantiation 'void std::basic_string::_Construct_from_iter(_Iter,const _Sent,_Size)' being compiled
2>        with
2>        [
2>            _Size_type=unsigned __int64,
2>            _Iter=wchar_t *,
2>            _Sent=wchar_t *,
2>            _Size=unsigned __int64
2>        ]
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xstring(2756,18):
2>see reference to function template instantiation '_OutIt *std::_Copy_n_unchecked4(_InIt,_SizeTy,_OutIt)' being compiled
2>        with
2>        [
2>            _OutIt=char *,
2>            _Size=unsigned __int64,
2>            _InIt=wchar_t *,
2>            _SizeTy=unsigned __int64
2>        ]
2>zmq_wrap.cpp
2>Done building project "AsyncDLLMQL.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 2 failed, 0 skipped ==========
========== Rebuild completed at 12:27 AM and took 01.698 seconds =========
Как я могу это решить?

Подробнее здесь: https://stackoverflow.com/questions/796 ... eating-dll
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»