简体   繁体   English

在Visual C ++中将Win32 .lib与x64项目一起使用

[英]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.

相关问题 VS2008:没有将Win32 C ++项目转换为x64的选项? - VS2008: No option to convert Win32 C++ project to x64? 在 Unity 中使用 x64 c++ dll 会出现“不是有效的 Win32 应用程序错误” - Using x64 c++ dll in Unity gives “Is not a valid Win32 application error” 使用 Visual Studio 2010 在 win32 和 x64 之间构建时间的巨大差异 - Big difference in build time between win32 and x64 using Visual Studio 2010 在Visual Studio 2010中将项目从Win32移植到x64平台后加载了错误的ComCtl32.dll - Incorrect ComCtl32.dll is loaded after porting a project from Win32 to x64 platform in Visual Studio 2010 Visual Studio 中的“win32 项目”名称与 x86 或 x64 平台有什么关系 - what's the relation of "win32 project" name in visual studio to x86 or x64 platform Visual Studio将平台更改从x64还原为Win32 - Visual Studio Reverts Platform Change from x64 to Win32 从Win32项目链接到x64库时,为什么会有链接错误? - Why there are link errors when linking from win32 project to x64 library? 程序在x64中崩溃,在Win32中运行良好 - Program crash in x64, works fine in Win32 提升进程间 Win32、x64 - Boost interprocess Win32, x64 什么是Visual C ++中的Win32项目? - What is win32 project in visual c++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM