Jump to content
  • Advertisement
Sign in to follow this  
DragonGeo2

Linking Main

This topic is 4416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I'm trying to make a minimal-size executable, and I managed to remove all default libraries from my project. However, since I did this, the linker now fails to locate "_mainCRTStartup". What library(ies) do I have to include in order to get my main function to work?

Share this post


Link to post
Share on other sites
Advertisement
_mainCRTStartup is the entrypoint for a console program, which calls your main function. You may be able to set the entrypoint directly to your main (in Visual Studio, don't know about other IDEs) by going to Project -> Properties -> Linker -> Advanced -> Entry Point.

However, without the CRT, I suspect you're very likely to run into other problems.

Share this post


Link to post
Share on other sites
Quote:
Original post by TheUnbeliever
_mainCRTStartup is the entrypoint for a console program, which calls your main function. You may be able to set the entrypoint directly to your main (in Visual Studio, don't know about other IDEs) by going to Project -> Properties -> Linker -> Advanced -> Entry Point.

However, without the CRT, I suspect you're very likely to run into other problems.

But what library do I have to link in in order to get my program to link correctly?

Share this post


Link to post
Share on other sites
Try reading this:

http://www.codeproject.com/useritems/tlibc.asp

It will explain why it says there is no _mainCRTStartup. This is the REAL first function that is called by windows at the start of your program. This function then calls other functions, one of them being main. My guess is you have a program like:

int main() { /* stuff */ }

What you really need is to change that to the _mainCRTStartup function and then have THAT function call main. If that ISn't what is going on then I'm stumped, but I have a feeling that is what's happening.

Good luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!