[英]Using a win32 .lib with a x64 project in Visual C++
I have a C++ library (downloaded here ). 我有一个C ++库( 在此处下载)。 In the library, there are some ".h" header files, ".cc" files containing the code and two static ".lib" that are included in a "win32" folder.
在库中,有一些“ .h”头文件,包含代码的“ .cc”文件和包含在“ win32”文件夹中的两个静态“ .lib”文件。 I am doing solely a x64 project in Visual Studio 2012 C++.
我只在Visual Studio 2012 C ++中执行x64项目。
In order to use the library, I specified, in the "Additional Include Directories" of the property page, the path to the .h files. 为了使用该库,我在属性页的“其他包含目录”中指定了.h文件的路径。 In the "Additional Library Directories", I specified the path to the folder containing both ".lib" files.
在“其他库目录”中,我指定了包含两个“ .lib”文件的文件夹的路径。 In the "Additional Dependencies", I put the name of all the ".lib" files that could be found in the "Additional Library Directories".
在“其他依赖项”中,我放置了在“其他库目录”中可以找到的所有“ .lib”文件的名称。 In the "Debug" mode, I use the debug version of the libraries if available.
在“调试”模式下,我使用库的调试版本(如果有)。
In the code, I add an #include < brisk.h> to indicate that I want to use that library. 在代码中,我添加了一个#include <brisk.h>来指示我要使用该库。 I also use other libraries but they cause no error.
我也使用其他库,但它们不会导致任何错误。
Now, I have a 现在,我有一个
"LNK2019 unresolved external symbol "public: __cdecl cv:: ...etc"
error at compilation. 编译时出错。 I wonder if this could be caused by the facts that some ".lib" are maybe compiled in win32 instead of x64.
我想知道这是否可能是由于某些“ .lib”可能是在win32而不是x64中编译的事实引起的。 Is that a possible error?
那可能是错误吗?
If it is evident I am doing something wrong, please tip me. 如果很明显我做错了,请给我小费。 I have consulted this question but I am not so sure...
我已经咨询了这个问题,但是我不确定...
Edit : 编辑:
Here is the output of the compiler: 这是编译器的输出:
1>------ Build started: Project: BRISK_opencv2, Configuration: Debug x64 ------
1> BRISK_opencv2.cpp
1>BRISK_opencv2.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::BriskDescriptorExtractor::BriskDescriptorExtractor(bool,bool,float)" (??0BriskDescriptorExtractor@cv@@QEAA@_N0M@Z) referenced in function main
1>BRISK_opencv2.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::BriskFeatureDetector::BriskFeatureDetector(int,int)" (??0BriskFeatureDetector@cv@@QEAA@HH@Z) referenced in function main
1>C:\...\x64\Debug\BRISK_opencv2.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You can't use 32-bit and 64-bit code in the same process. 您不能在同一过程中使用32位和64位代码。
The linker should tell you if it is skipping input files you instructed it to use due to an incompatible architecture. 链接器应告诉您,由于体系结构不兼容,链接器是否正在跳过您指示使用的输入文件。 Read all the linker output, not just the errors.
读取所有链接器输出,而不仅仅是错误。
Use 采用
dumpbin win32.lib /headers
The line starting with machine will tell you what sort of architecture it is expecting 以机器开头的行将告诉您期望使用哪种架构
At the end of FILE HEADER VALUES, before OPTIONAL HEADER VALUES, it will tell you whether it is expecting 32-bit or 64 bit. 在FILE HEADER VALUES的末尾,在OPTIONAL HEADER VALUES之前,它将告诉您期望使用32位还是64位。
It could be that the lib is for 64 bit but IA64 instead of X64. 可能是该库用于64位,但使用IA64而不是X64。 That would still be incompatible.
那仍然是不兼容的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.