none
Linkage problem in C++ code DirectShow related. RRS feed

  • Question

  • I have this code and I get a compile time error. The problem seems to be a linkage problem.

    #include "stdafx.h"
    #include <iostream>
    #include "dshow.h"
    #include "Form1.h"  // This line added
    
    using namespace System;
    using namespace System::Windows::Forms;  // This line added
    using namespace std;
    using namespace Visual_CPlusPlus3;       //This line added 
    [STAThreadAttribute]  // This line added
    
    int main2(cli::array<System::String ^> ^args)
    {
    	Application::EnableVisualStyles();  // This line added
    	Application::SetCompatibleTextRenderingDefault(false);  // This line added
    	Application::Run(gcnew Form1());  // This line added
    	std::cout << "\nHello World\n";
    	Console::WriteLine("Hello World");
    	return 0;
    }  

    There are two errors:

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	LNK1120	1 unresolved externals	Visual_CPlusPlus3	C:\CPlusPlus_Projects\Visual_CPlusPlus3\Visual_CPlusPlus3\Debug\Visual_CPlusPlus3.exe	1	
    
    
    Severity	Code	Description	Project	File	Line	Suppression State
    Error	LNK2019	unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)	Visual_CPlusPlus3	C:\CPlusPlus_Projects\Visual_CPlusPlus3\Visual_CPlusPlus3\MSVCRTD.lib(exe_main.obj)	1	
    

    Need help.

    Thank you, -MyCatAlex

    Sunday, January 13, 2019 10:46 PM

Answers

All replies

  • Change main2 to main here -

    int main2(cli::array<System::String ^> ^args)

    • Proposed as answer by Andrew B. Painter Sunday, January 13, 2019 11:22 PM
    • Marked as answer by MyCatAlex Monday, January 14, 2019 2:43 AM
    Sunday, January 13, 2019 10:52 PM
  • Change main2 to main here -

    int main2(cli::array<System::String ^> ^args)

    Thanks. That has been tried. It compiles and linkage is OK. It gives me run time exceptions. My weekend is over and the next post will be next Friday. Hopefully it will be resolved.

    - MyCatAlex

    Monday, January 14, 2019 2:43 AM