我正在评估升级到Windows SDK 7.1的过程
我团队的遗留代码库的一部分是大量的ATL Web服务,它们仍然使用Visual Studio 2005进行维护,因为(据我所知)2005年以后的版本不支持ATL Web服务.
当我将IDE指向SDK 7.1时,我开始收到以下链接错误:
uuid.lib(cguid_i.obj) : fatal error LNK1103: debugging information corrupt; recompile module
Run Code Online (Sandbox Code Playgroud)
我在VS2005和SDK 7.1中无法在网络上找到与此问题相关的内容.我在2005年发现了一些关于同样错误的论坛帖子 - 它们似乎表明SDK不兼容.
基于下载页面,我的印象是Windows SDK 7.1可以与Visual Studio 2005一起使用(尽管我注意到"并非所有功能都适用于所有版本的Visual Studio"免责声明).
这是一个已知问题,还是我的配置不正确?
我希望有人可以分享他们的经验或建议如何/如果我能够解决这个问题.
编辑:我发现通过在链接器命令行上禁用/ DEBUG可以避免此问题.虽然允许构建完成,但这不是最理想的,因为它阻止了在将来的维护期间进行调试.
编辑:显然问题没有明确表达.我遇到的问题是,当在头文件中定义析构函数时,它会被添加到多个.obj文件中并且链接器会抱怨.实际问题是:
当我将析构函数添加到DLL项目中的CPP文件并使用动态加载的dll和接口头文件时,基本析构函数是否仍然被调用以防止内存泄漏?
我正在使用MSVC 10.0并有一个实现接口的DLL项目.该接口是一个抽象(纯虚拟)基类.这个想法是标题用于动态加载库.因此,我使用了一个纯虚拟析构函数来确保调用基类中的析构函数.以下是解释此问题的示例代码:
//ISplitter.h
#pragma once
struct param {
int something;
}
class ISplitter {
public:
virtual ~ISplitter() = 0;
virtual void useful() = 0;
}
ISplitter::~ISplitter() {
/* Make sure base class destructor gets called */
}
Run Code Online (Sandbox Code Playgroud)
和主要的实现标题
//CSplitter.h
#pragma once
#include "CHelper.h"
#include "ISplitter.h"
class CSplitter : public ISplitter {
private:
CHelper hlp;
public:
~CSplitter();
void useful();
}
Run Code Online (Sandbox Code Playgroud)
一些助手班
//CHelper.h
#pragma once
#include "ISplitter.h" // I need the struct
// Class definition should go here but is …Run Code Online (Sandbox Code Playgroud) 大家好,我只想练习一些c ++模板,但我得到链接器错误.有人能帮帮我吗?这是我的代码:
// File: MyClass.h
#ifndef _MYCLASS_H
#define _MYCLASS_H
template<class T> class MyClass {
T value;
public:
MyClass(T v);
~MyClass();
};
#endif // _MYCLASS_H
// File: MyClass.cpp
#include "MyClass.h"
template<class T> MyClass<T>::MyClass(T v) {
value = v;
}
template<class T> MyClass<T>::~MyClass() {
}
// File: main.cpp
#include "MyClass.h"
int main() {
MyClass<int> test(10);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是命令行输出:
g++ main.cpp -c
g++ MyClass.cpp -c
g++ main.o MyClass.o -o Out
main.o: In function `main':
main.cpp:(.text+0x1a): undefined reference to `MyClass<int>::MyClass(int)'
main.cpp:(.text+0x2b): undefined reference …Run Code Online (Sandbox Code Playgroud) 我讨厌这些链接器错误,任何想法我怎么能摆脱它们?
Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\**********\Documents\Visual Studio 2005\Projects\Machine2\Debug\Machine2.exe
Run Code Online (Sandbox Code Playgroud)
和
Error 1 error LNK2001: unresolved external symbol "public: void __thiscall SecondDlg::OnBnClickedButton4(void)" (?OnBnClickedButton4@SecondDlg@@QAEXXZ) SecondDlg.obj
Run Code Online (Sandbox Code Playgroud) 当我尝试使用编译程序时make,出现了对主错误的未定义引用。但是,main存在于我的src目录中,我对自己做错的事情感到困惑。
我假设这add_executable([title] [source])是用于将源文件添加到编译中的命令。
基于cmake教程
cmake_minimum_required(VERSION 2.6)
project(opengl_02)
add_executable(opengl_02 opengl_02.cpp)
add_executable(main main.cpp)
add_executable(geometrics geometrics.cpp)
set (opengl_02_version_major 1)
set (openfl_02_version_minor 0)
#configure the header file to pass some of the CMake settings
#to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/opengl_02_config.h.in"
"${PROJECT_BINARY_DIR}/opengl_02_config.h"
)
#add the binary tree to the search path for include files
#so that it will find tutorialconfig.h
include_directories("{PROJECT_BINARY_DIR}")
add_executable(opengl_02_config opengl_02_config.cpp)
Run Code Online (Sandbox Code Playgroud)
题
为什么我的主文件没有被引用?
我在编译设备时遇到了以下错误
File is universal (3 slices) but does not contain a(n) armv7s slice: /Users/xxx/Desktop/xxxxxxx/DropboxSDK.framework/DropboxSDK for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我已检查所有.m文件是否链接,一切正常,为什么它只在设备上执行此操作,编译器想要阻止它抱怨什么?
我一直在试图寻找一个解决方案.我想继承一个带有静态指针的类,但我是geterror LNK2001:未解析的外部符号"protected:static class cGame*cEvent :: mGame"(?mGame @ cEvent @@ 1PAVcGame @@ A)
最后我会初始化我的类cEvent一次,然后不要在继承的类中传递指针.
#ifndef EVENT_H
#define EVENT_H
#include "game.h"
class cEvent
{
protected:
static cGame* mGame;
public:
cEvent(){;}
virtual void doEvent(){;}
};
class cEventExitButton: public cEvent
{
private:
public:
cEventExitButton(cGame *g){mGame = g;}
void doEvent(){mGame->getWindow()->close();}
};
#endif
Run Code Online (Sandbox Code Playgroud) 谁能告诉我发生了什么事?
包括AFnetworking后我得到9个错误,见下文.


我的系统中有一个makefile项目。最近,我添加了一些使用以下Windows API的新功能:
RegOpenKeyEx
RegEnumKeyEx
RegCloseKey
RegGetValue
Run Code Online (Sandbox Code Playgroud)
为了拥有这些API,我还添加了windows.h头文件。代码可以在我的机器上正常编译和链接。但是,在我的同事机器中链接失败。我们都在64位Windows计算机上工作。在他的电脑上,我得到了错误:
错误LNK2001:无法解析的外部符号__imp_RegOpenKeyExW
错误LNK2001:无法解析的外部符号__imp_RegGetValueW
错误LNK2001:无法解析的外部符号__imp_RegCloseKey
错误LNK2001:无法解析的外部符号__imp_RegEnumKeyExW
我尝试过的:由于正在使用的库Advapi32.lib位于C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64
我尝试添加以下行:
LINKFLAGS + = -L“ C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ Lib \ x64”
我将库的路径添加到环境变量 PATH
我将库复制到输出文件夹。
没事。
如前所述,该代码在我的PC上运行正常,但在另一台PC上失败。
我有一个虚拟类,定义如下:
template<typename TId, typename TValue>
class Resource {
private:
/// Next item in the chain
unique_ptr<Resource<TId, TValue>> data;
protected:
/// The id this value
TId id;
/// The value on this value
TValue value;
public:
/// Create a new instance and assign the values to it
Resource(TId id, TValue value) {
this->id = id;
this->value = value;
}
/// Destructor
virtual ~Resource() {
}
/// Safely clone a new instance of this
virtual Resource<TId, TValue> *Clone();
... other stuff removed …Run Code Online (Sandbox Code Playgroud) linker-errors ×10
c++ ×8
ios ×2
templates ×2
winapi ×2
afnetworking ×1
cmake ×1
compilation ×1
dropbox ×1
memory-leaks ×1
objective-c ×1
registry ×1
static ×1
visual-c++ ×1
windows ×1
xcode ×1