'error: LNK 2005 when i include regex, vector, or curlpp in c++ CLR
I'm new to C++ CLR development. I'm trying to develop a GUI app but when i include vector/regex/curlpp i get an error while compiling LNK 2005. Anyone have any idea how to get around this problem.
I'm using visual studio 2022 version
MyForm.h
#pragma once
namespace Calculator {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::TextBox^ textBox3;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->textBox1->Location = System::Drawing::Point(18, 27);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(72, 29);
this->textBox1->TabIndex = 0;
//
// textBox2
//
this->textBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->textBox2->Location = System::Drawing::Point(194, 27);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(72, 29);
this->textBox2->TabIndex = 1;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 12, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(96, 32);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(88, 20);
this->label1->TabIndex = 2;
this->label1->Text = L"Operation";
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(117, 55);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(45, 43);
this->button1->TabIndex = 3;
this->button1->Text = L"+";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// button2
//
this->button2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button2->Location = System::Drawing::Point(117, 104);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(45, 43);
this->button2->TabIndex = 4;
this->button2->Text = L"-";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// button3
//
this->button3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button3->Location = System::Drawing::Point(117, 153);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(45, 43);
this->button3->TabIndex = 5;
this->button3->Text = L"*";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);
//
// button4
//
this->button4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button4->Location = System::Drawing::Point(117, 202);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(45, 43);
this->button4->TabIndex = 6;
this->button4->Text = L"/";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
//
// textBox3
//
this->textBox3->Enabled = false;
this->textBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->textBox3->Location = System::Drawing::Point(18, 251);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(248, 29);
this->textBox3->TabIndex = 7;
this->textBox3->Text = L"Result";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 293);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int output = System::Convert::ToInt16(textBox1->Text) + System::Convert::ToInt16(textBox2->Text);
textBox3->Text = System::Convert::ToString(output);
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
int output = System::Convert::ToInt16(textBox1->Text) - System::Convert::ToInt16(textBox2->Text);
textBox3->Text = System::Convert::ToString(output);
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
int output = System::Convert::ToInt16(textBox1->Text) * System::Convert::ToInt16(textBox2->Text);
textBox3->Text = System::Convert::ToString(output);
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
double output = System::Convert::ToDouble(textBox1->Text) / System::Convert::ToDouble(textBox2->Text);
textBox3->Text = System::Convert::ToString(output);
}
};
}
MyForm.cpp
#include "MyForm.h"
#include <iostream>
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Calculator::MyForm form;
Application::Run(% form);
}
when i compile this i get this error Error i get when i compile the above code
Kindly help me fix it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|