# Creating a C++ project with Visual Studio 2010

I am trying to create a GUI using Microsoft Visual Studio C++ 2010 by calling Mathematica in my codes.

I have done everything step by step as mentioned here

Then I wrote this code as mentioned in here

The code is as below

#include <mathlink.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
MLENV env;
int errno;

env = MLInitialize(0);

link = MLOpenArgcArgv(env, argc, argv, &errno);

return 0;
}


The error I get is:

1>------ Build started: Project: mathematica_link_attempt1, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol _MLOpenArgcArgv@16 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _MLActivate@4 referenced in function _main


I cannot help you with Visual Studio, as I do not use it myself (I only used the command line tools), but looking at the error messages it seems like you are not linking against the MathLink libraries. Instead of writing your own code, first try to compile some of the supplied examples and figure out how to link against the correct libraries in Visual Studio. Make sure you also translate the .tm file and compile the resulting C file. After you've managed to compile and run the examples, you can start writing your own code. –  Szabolcs Jan 7 at 17:59
As Szabolcs says, the problem is that you aren't linking with the MathLink libraries. The docs you cite give a method of doing this, but you might find it easiest (and it's easiest to explain) to simply add the ml32i4m.lib file to your Visual Studio project. (Use ml64i4m.lib, of course, if you are building a 64-bit program.) Right-click on your project in the Solution Explorer and select Add/Existing Item. In the dialog box that comes up, navigate to <mathematica dir>\SystemFiles\Links\MathLink\DeveloperKit\Windows\CompilerAdditions\mldev32\lib\ml32i4m.lib. The build should now work. For a 64-bit program, the correct path is <mathematica dir>\SystemFiles\Links\MathLink\DeveloperKit\Windows-x86-64\CompilerAdditions\mldev64\lib\ml64i4m.lib.