版权所有,转载请注明出处:http://guangboo.org/2013/01/17/solution-link-errorcannot-open-file-python27_dlib
使用C调用Python函数或解释器时,在添加了Include Directories和Library Directories等配置后,仍然编译错误:"LINK : fatal error LNK1104: cannot open file 'python27_d.lib'".代码如下:
#include <stdio.h>
#include <Python.h>
int main(void)
{
Py_Initialize();
if(!Py_IsInitialized()){
printf("Python Initialize failed.\n");
return 1;
}
PyRun_SimpleString("print('hello world!')");
Py_Finalize();
system("pause");
return 0;
}
Stackoverflow贴出了pyconfig.h头文件中对Python27_d.lib的引用(http://stackoverflow.com/questions/11311877/creating-a-dll-from-a-wrapped-cpp-file-with-
swig/14372472#14372472),该文件用于调试用,如下代码:
/* For Windows the Python core is in a DLL by default. Test
Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
# define MS_COREDLL /* deprecated old symbol */
#endif /* !MS_NO_COREDLL && ... */
/* All windows compilers that use this header support __declspec */
#define HAVE_DECLSPEC_DLL
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
# ifndef Py_BUILD_CORE /* not building the core - must be an ext */
# if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally
taken care of by distutils.) */
# ifdef _DEBUG
# pragma comment(lib,"python27_d.lib")
# else
# pragma comment(lib,"python27.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */
可以发现,只有MS_NO_COREDLL或Py_NO_ENABLE_SHARED被定义了,那么#ifdef MS_COREDLL块的代码就不会被编译。因此可以在Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions添加MS_NO_COREDLL或Py_NO_ENABLE_SHARED,去掉_DEBUG,将没有效果。也可以在引用python.h头文件前添加#define MS_NO_COREDLL或#define Py_NO_ENABLE_SHARED。
分享到:
相关推荐
ERP信息化专业资料:SAP专业学习资料BI_Solution.ppt
(EE) AIGLX error: dlopen of /usr/lib64/dri/swrast_dri.so failed (/usr/lib64/dri/swrast_dri.so: cannot open shared object file: No such file or directory) (EE) GLX: could not load software renderer The...
solution_04_ETL_with_python_and_postgres.ipynb
ERP信息化专业资料:SAP专业学习资料IMC_Solution_Scope_ZH.old.doc
Full_file_at_https_testbanku.eu_Solution_research_源码.zip
ERP信息化专业资料:SAP专业学习资料IMC_Solution_Scope_ZH.doc
ERP信息化专业资料:SAP专业学习资料IMC_Solution_Scope.doc
英文经典,SPSS中ARIMA算法的两个参考文献之一,ARIMA时间序列分析建模必备。附djvu格式阅读器。
Our package gives you a complete solution to develop and control Internet based application. It allow you to create a customized Web browsing application, add Internet, file and network browsing, ...
xilliix pcie dma 驱动 (基于 xilnx xdma ip核 4.0 的WDF驱动) --- # XDMA Windows Driver This project is Xilinx's sample Windows driver for 'DMA/Bridge ...|__ XDMA.sln - Visual Studio Solution. ```
打印机驱动M1536,不错,很好用,32位版本,hp_M1530_MFP_Basic_Solution_15188.exe
HP打印机驱动。适用于LJM1130、M1210等MFP系列。惠普打印机将低廉的价格与丰富的实用功能集于一身,定位于中小企业和SOHO办公用户,支持多种办公功能,能满足日常普通的办公应用。
Color_LJPro_MFP_M176_full-solution_15321.exe
4)....Added "--el_injectjcl", "--el_createjcl", and "--el_createdbg" command-line options for ecc32/emake to inject JEDI/JCL debug info, create .jdbg file, and create .dbg file (Microsoft debug format...
John_G._Proakis.Digital_Signal_Processing_solution
HP_M125-126打印机驱动
该文档是学习halcon的帮助文档,一共有22章,每个章节描述不同的处理图像的方法,有一维测量、blob分析等图像处理方式。
Alarmy_-_Alarm_Clock_Solution_v5.71.03_Patched_yxssp.com.apk
Chapter 3: Linear Models for Regression . . . . . . . . . . . . . . . . . . 34 Chapter 4: Linear Models for Classification . . . . . . . . . . . . . . . . 41 Chapter 5: Neural Networks . . . . . ....