我的程序无法在/ MT(MultiThreaded)模式下成功编译.它在/ MD(MultiThreaded DLL)中编译.我希望能够在我将使用安装程序分发的应用程序中同时使用libcurl和boost.
编译于:MSVS2010
这是复制我的问题的代码:
#include "stdafx.h"
#include "boost/regex.hpp"
#include "curl/curl.h"
int _tmain(int argc, _TCHAR* argv[])
{
CURL *curl;
curl = curl_easy_init();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果处于/ MD模式,这是我得到的警告:
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs;
use /NODEFAULTLIB:library
Run Code Online (Sandbox Code Playgroud)
如果我尝试在/ MT模式下编译,我得到:
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc already defined in
LIBCMT.lib(calloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _realloc already defined in LIBCMT.lib(realloc.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj) …Run Code Online (Sandbox Code Playgroud) 我使用托管代码和非托管代码创建了一个非常简单的C++ .NET应用程序来复制我的问题.
当用户单击一个按钮时,新的线程应该生成并执行一些耗时的任务,同时通过状态更新回调我的主线程.
此代码在Visual Studios Express 2010中编译并成功执行.也就是说,当我单击"播放"按钮时,我的项目构建并执行而不会崩溃.但是,如果我转到可执行文件所在的Release文件夹并运行它,则单击该按钮后应用程序将崩溃.我正在使用/ clr和Release模式进行编译.
我创建一个表单并添加一个按钮.这就是Form1.h的代码:
#pragma once
#include "core.h"
#include <Windows.h>
#include <process.h>
namespace RepErr {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
int x;
/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources …Run Code Online (Sandbox Code Playgroud)