windows-seafile-client编译基本错误

1、“strncasecmp”: 找不到标识符
#if _MSC_VER
#define strncasecmp _strnicmp  
#endif

2、不能将参数2 从“char [256]”转换为“LPWSTR”
//Wchar_tToString转换函数
void Wchar_tToString(std::string& szDst, wchar_t *wchar)
{
    wchar_t * wText = wchar;
    DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, NULL, 0, NULL, FALSE);// WideCharToMultiByte的运用
    char *psText;  // psText为char*的临时数组,作为赋值给std::string的中间变量
    psText = new char[dwNum];
    WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, psText, dwNum, NULL, FALSE);// WideCharToMultiByte的再次运用
    szDst = psText;// std::string赋值
    delete[]psText;// psText的清除
}


3、const char*类型的实参与LPCWSTR的类型的形参不兼容
ext_handler.cpp
/*利用CString做一下中间转换。
#include <afx.h>
const char *str = "fasdfgfghe";
CString temp = str;
LPCWSTR app = (LPCWSTR)(temp.AllocSysString());
这样就把str转化成LPCWSTR类型的app了*/

将CreateNamedPipe函数修改为CreateNamedPipeA函数。这样子第一个参数的类型就是LPCSTR了。

4、vs2015使用getopt_long五个参数那个函数,修改getopt.h头文件
//#if __STDC__ || defined(PROTO)
#if __STDC__ || defined(__cplusplus)

5、crash_handler.cpp中
CrashHandler报错。
其实是在crash_handler.h缺乏定义,可以查看CMakeLists.txt。
这里是直接定义该宏。
//#ifdef SEAFILE_CLIENT_HAS_CRASH_REPORTER //modify by ckc
#ifndef SEAFILE_CLIENT_HAS_CRASH_REPORTER
#define SEAFILE_CLIENT_HAS_CRASH_REPORTER

6、pthread.h提示error C2011: “timespec”:“struct”类型重定义

在使用的项目属性->C/C++->预处理器定义->添加“HAVE_STRUCT_TIMESPEC”。

7、error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Plea
主要是因为在第三个中,包含了#include <afx.h>。
属性、配置属性、常规,然后右边有个“项目默认值”,下面有个MFC的使用,选择“在共享 DLL 中使用 MFC”
然后越陷越深,又出现了错误
1>D:\vs2015\VC\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error:  WINDOWS.H already included.  MFC apps must not #include <windows.h>
所以,还是修改,第三个“const char*类型的实参与LPCWSTR的类型的形参不兼容”的问题。不使用CString了。

8、error C2036: “void *”: 未知的大小

例如是void *p = (void *)(&priv->cmd);

改为void *p = (LPVOID*)(&priv->cmd)即可。

LPVOID是一个没有类型的指针,也就是说你可以将LPVOID类型的变量赋值给任意类型的指针,比如在参数传递时就可以把任意类型传递给一个LPVOID类型为参数的方法,然后在方法内再将这个"任意类型"从传递时的"LPVOID类型"转换回来。


9、编译libsearpc动态库的时候
ssize_t的问题,在windows下使用。
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

10、QString::fromLocal8Bit(info.szDevice)
QString::fromLocal8Bit(const QByteArray &str)
而info.szDevice)是wchar_t(WCHAR)类型

>src\utils\utils-win.cpp(172): error C2665: “QString::fromLocal8Bit”: 2 个重载中没有一个可以转换所有参数类型
1>  D:\QtVs2015\Qt5.9.2\5.9.2\msvc2015\include\QtCore/qstring.h(548): note: 可能是“QString QString::fromLocal8Bit(const QByteArray &)”
1>  D:\QtVs2015\Qt5.9.2\5.9.2\msvc2015\include\QtCore/qstring.h(540): note: 或  “QString QString::fromLocal8Bit(const char *,int)”
1>  src\utils\utils-win.cpp(172): note: 尝试匹配参数列表“(WCHAR [32])”时

error C2665: “QString::fromLocal8Bit”: 2 个重载中没有一个可以转换所有参数类型
解决:
//fromLocal8Bit
  类型不对 
 if (QString::fromWCharArray(info.szDevice) == QLatin1String("WinDisc")) {

11、编译libseafile的时候。
11.1 编译libseafile.dll
1)、“mode_t”: 形参表中的名称非法
在utils.c中,在windows可以使用unsigned int来替代。
#define unsigned int mode_t

2)1>net.obj : error LNK2001: 无法解析的外部符号 __imp__WSAGetLastError@0
1>event.lib(evutil.obj) : error LNK2001: 无法解析的外部符号 __imp__WSAGetLastError@0
1>event.lib(signal.obj) : error LNK2001: 无法解析的外部符号 __imp__WSAGetLastError@0
但是我确定是libevent的编译结果是,release,win32.
工程位置:E:\seafile-client-windows\libevent-master\builder
忘记在seafile_pro加:
ws2_32.lib
wsock32.lib
然后剩下:
1>utils.obj : error LNK2001: 无法解析的外部符号 _EnumProcessModules@16
1>utils.obj : error LNK2001: 无法解析的外部符号 __imp__RpcStringFreeA@4
1>utils.obj : error LNK2001: 无法解析的外部符号 _EnumProcesses@12
1>utils.obj : error LNK2001: 无法解析的外部符号 __imp__UuidToStringA@8
1>utils.obj : error LNK2001: 无法解析的外部符号 __imp__UuidFromStringA@8
1>utils.obj : error LNK2001: 无法解析的外部符号 _GetModuleBaseNameA@16
1>utils.obj : error LNK2001: 无法解析的外部符号 __imp__UuidCreate@4
1>..\x86_Release_Bin\libseafile-6.dll : fatal error LNK1120: 7 个无法解析的外部命令
这些函数是可以在本项目中找到的。
通过查找GetModuleBaseNameA是在哪个函数,这里的这个是psapi.h,然后一般对应其静态库。可以去Windows Kits工具集里面搜一下,就可以知道有一个psapi.lib。将其直接输入到附加依赖项即可。
缺乏psapi.lib:GetModuleBaseName,EnumProcessModules,EnumProcesses三个错误
缺乏Rpcrt4.lib,解决其他错误。


1>exception_handler.lib(exception_handler.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1900”(moc_about-dialog.obj 中)
1>exception_handler.lib(exception_handler.obj) : error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“2”不匹配值“0”(moc_about-dialog.obj 中)
1>exception_handler.lib(exception_handler.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MDd_DynamicDebug”不匹配值“MD_DynamicRelease”(moc_about-dialog.obj 中)
因为之前生成的googleBreakpad的lib是MT类型的。运行库需要更改为:多线程DLL/MD。也是release版本的。

4)还要生成quazip的库。
E:\seafile-client-windows\quazip-0.7.3\quazip.pro打开,已经设置好,直接Release编译即可。
编译成dll或者lib的依赖dll必须放在一起


5)registry.obj : error LNK2019: 无法解析的外部符号 __imp__SHDeleteKeyW@8,该符号在函数 "public: static int
通过前面的方法,找到这里的这个SHDeleteKeyW函数是在Shlwapi.lib中。

6)
1>  正在生成代码...
1>rpc-client.obj : error LNK2019: 无法解析的外部符号 __imp__seafile_get_repo_list,该符号在函数 "public: int __thiscall SeafileRpcClient::listLocalRepos(class std::vector<class LocalRepo,class std::allocator<class LocalRepo> > *)" (?listLocalRepos@SeafileRpcClient@@QAEHPAV?$vector@VLocalRepo@@V?$allocator@VLocalRepo@@@std@@@std@@@Z) 中被引用
1>rpc-client.obj : error LNK2019: 无法解析的外部符号 __imp__seafile_repo_get_type,该符号在函数 "public: int __thiscall SeafileRpcClient::getLocalRepo(class QString const &,class LocalRepo *)" (?getLocalRepo@SeafileRpcClient@@QAEHABVQString@@PAVLocalRepo@@@Z) 中被引用
1>rpc-client.obj : error LNK2019: 无法解析的外部符号 __imp__seafile_sync_task_get_type,该符号在函数 "public: void __thiscall SeafileRpcClient::getSyncStatus(class LocalRepo &)" (?getSyncStatus@SeafileRpcClient@@QAEXAAVLocalRepo@@@Z) 中被引用
1>rpc-client.obj : error LNK2019: 无法解析的外部符号 __imp__seafile_diff_entry_get_type,该符号在函数 "public: bool __thiscall SeafileRpcClient::getCommitDiff(class QString const &,class QString const &,class QString const &,class CommitDetails *)" (?getCommitDiff@SeafileRpcClient@@QAE_NABVQString@@00PAVCommitDetails@@@Z) 中被引用
1>rpc-client.obj : error LNK2019: 无法解析的外部符号 __imp__seafile_encryption_info_get_type,该符号在函数 "public: int __thiscall SeafileRpcClient::generateMagicAndRandomKey(int,class QString const &,class QString const &,class QString *,class QString *)" (?generateMagicAndRandomKey@SeafileRpcClient@@QAEHHABVQString@@0PAV2@1@Z) 中被引用

这些函数都是在seafile-object.h或者seafile.h中定义的。因为是无法解析valac生成的代码。
将repo.c和task.c中和他们生成的seafile-object.h中比较,去掉重复定义的。就可以正常生成dll了。
 

猜你喜欢

转载自blog.csdn.net/caokunchao/article/details/81234003