trying to build an app with MSVC

Hi -

I have a very small app that I developed with MinGW. I now want to try to make the code portable to MSVC2010. (The end goal is to build a standalone application that I can distribute to my customer with no libraries needed.)

First issue: here's the command line my IDE (Qt Creator) generates:

link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /MANIFEST /MANIFESTFILE:"debug\storefile_client.intermediate.manifest" /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /OUT:debug\storefile_client.exe @C:\Users\Mike\AppData\Local\Temp\storefile_client.exe.8384.421.jom

And I'm getting this error:

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup


Any idea what's going on here? (I'm pretty unfamiliar with MSVC.)

Thanks.
You are missing the executable entry point. Are you trying to compile a console application as a windows GUI project ?
Last edited on
I'm not sure I understand the question, but it's not a GUI application...just writes a few telltales to a console window.

When you say I'm "missing the executable entry point," what does this mean? I have a main() declared in my (only) .cpp file. And, this does build using MinGW.
I'm using VS2010 (not sure if the interface is exactly the same for my suggestion) but I'd suggest the following:

Open Visual Studio from scratch and go to File -> New -> Project.

Choose and create a new "Empty Project".

Import your source files in your project and try building the solution (Build -> Build Solution). For console applications this project setup should cause no problems.
Last edited on
OK, I don't mean to take this discussion too far off-topic, but...I followed your instructions below. When I click on the .sln file, it tells me I need something called ".NETFramework,Version=4.0."

I have a .NETFramework folder in Reference Assemblies\Microsoft\Framework, and it contains a v4.5 folder. Do I really need this 4.0 version, or so I need to add something to my path variable, or do I have to do something else?
I don't think so. Maybe someone else can answer this. I have folders 3.0, 3.5 and 4.0 in the same directory (so I do have framework 4.0) but my instructions didn't involve clicking on any .sln file.

I could be wrong and you might need framework 4.0, but let me be clear and say again:

- Close any running instances of Visual Studio you may currently have open.

- Run Visual Studio from your Start Menu or Desktop shortcut etc -- run Visual Studio itself, not any solution (.sln) files you may have generated.

- Once inside Visual Studio, you should be seeing an empty workspace, no previous projects currently loaded etc. . Then go to File -> New -> Project and you will get a window with various project types -- you need to find an "Empty Project". (In the top of this window there is a drop-down list where you can choose the .NET framework for your project -- mine defaults at 4.0 but like I said I do have 4.0. So if you continue having problems you could change this to a version you have installed if it is listed there -- do you see a 4.5 option?)

- Once you create the "Empty Project", don't change any of the settings, just look for a default folder in the left of the workspace that is named "source files". Right-click and choose Add -> Existing Item. Navigate to your cpp files and add them in. Then just go to Build -> Build Solution. This should generate an .exe file in the "Debug" folder found inside the directory you specified for your project to be saved. So at this point, if you go to "Debug", you can find and run your compiled program independently of Visual Studio.

Does this work for you? If not, it may have to do with your .NET framework setting on creating the project, I'm not sure.
Last edited on
Thanks for the detailed steps on this. I still have something configured wrong, though, I think...I get an error when I try to create that empty project. A couple of notes:

1. I'm using MSVC2010 *Express* -- not sure if this makes a difference.
2. Possibly because of #1 above, I don't see the drop-down list you mention.
3. When I try to create the empty project, I get a message saying an error occurred in creating a .sdf file. It tells me to ensure that Microsoft SQL Server Compact 3.5 is installed. (It wasn't, but I installed it, and am getting the same error.)

Any ideas here? Maybe I should uninstall MSVC2010 and reinstall?

Thanks for your patience; I'm not as clueless as I probably look here.
Use /SUBSYSTEM:CONSOLE linker command line option if you want to build a console application. It is documented in MSDN all command line switches.

In windows a console application has main() entry point, a GUI application has WinMain() entry point, a DLL has DllMain, etc I hope you get the point. For MinGW it is the same behaviour (different command line switches, entry points are the same).
This is what modoran is referring to:

http://msdn.microsoft.com/en-us/library/fcc1zstk%28v=vs.71%29.aspx

You'd have to go to Project -> (Project-name's) Properties -> Configuration Properties -> Linker -> System -> Subsystem to change this setting.

On a different note, the lack of the .NET framework version selection got me wondering. As I read here, express editions of Visual Studio don't allow specifying a .NET Framework version (other than the default) when creating a project. (You can set the option later, however. See the provided link below.)

http://msdn.microsoft.com/en-us/library/bb398202.aspx
Last edited on
Thanks for the information. I decided to uninstall/reinstall MSVC along with all my .NET and SQL stuff.

I'm still getting an error I mentioned above (about the .sdf file) when I try to create the project. I've reinstalled SQL Server Compact 3.5 with the same results. Any suggestions?

EDIT: I forgot to mention that I did somehow manage to get rid of that console vs. GUI issue I was having. Now, when I build in Qt, I can create an image. Once I get this .sdf file error resolved, the next step will be to successfully launch the image from outside of Qt (or MSVC).
Last edited on
Good to know. I've never had this error occur but from what I read installing Microsoft SQL Server Compact 3.5 SP 2 (http://www.microsoft.com/en-us/download/confirmation.aspx?id=5783) resolved it for others, although apparently the error keeps coming up for you even after installation.
Hey! That seems to have worked. Good find.

So, I followed your steps above, and the solution was created. I imported my source file, and my two header files. The build fails, though...it can't find one of the header files. This particular file is in a different directory; do I need to specify a pathname somewhere in the IDE?

Thanks!
You're welcome, glad it got resolved. If you go to Project -> (Project name's) Properties -> Configuration Properties -> VC++ Directories you'll see the directories set for your project to look into at compilation time. You're probably looking for the "Include Directories".
Last edited on
Beautiful...thanks for the help.
Topic archived. No new replies allowed.