Author Topic: setting the entry point in visual studio community 2017  (Read 39 times)

markallyn

  • Member
  • **
  • Posts: 63
setting the entry point in visual studio community 2017
« on: October 17, 2017, 01:13:09 AM »
Hello everyone,

I have two procs structured as follows:
Quote

.code
main PROC
.
call IntegerAdd_
.
main ENDP

IntegerAdd_ PROC
.
.
.
IntegerAdd_ ENDP
END

When the above code is assembled, the linkier compains that there is an unresolved external symbol mainCRTStartup.  If I change "main" in the first PROC to "mainCRTStartup", everything works as expected.  Mind you, I am building this code with Visual Studio Community 2017.  The 2017 IDE seems to not let me set the entry point to anything other than mainCRTStartup. 

Could someone explain what is going on here? 

Thanks,
Mark Allyn

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4807
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: setting the entry point in visual studio community 2017
« Reply #1 on: October 17, 2017, 01:19:12 AM »
Mark,

See if this linker option does what you need.

/ENTRY:main
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

markallyn

  • Member
  • **
  • Posts: 63
Re: setting the entry point in visual studio community 2017
« Reply #2 on: October 17, 2017, 01:23:29 AM »
Hello everyone,

If I work off the command line, however, and set the the entry point with the linker option /ENTRY:main, all proceeds well.  If I don't use the ENTRY option, then the linker wants to find mainCRTStartup.  So, from this I conclude that the VS 2017 IDE:

1.  Defaults to the insertion of mainCRTStartup as the entry point, and worse,
2.  Will NOT allow users to select their own entry points.

Am I correct in this conclusion?

Regards,
Mark Allyn

markallyn

  • Member
  • **
  • Posts: 63
Re: setting the entry point in visual studio community 2017
« Reply #3 on: October 17, 2017, 01:26:36 AM »
Good morning, Hutch,

Your response to my initial post came in while I was writing my second post.  As you can see, I got to the same place you did.  But, still, am I right that VS won't allow users to pick their own entry points?  On one of MSFT's pages I read that they really don't like people picking their own and claim that they can get into all sorts of trouble if they do.

Thanks,
Mark

aw27

  • Member
  • ****
  • Posts: 697
Re: setting the entry point in visual studio community 2017
« Reply #4 on: October 17, 2017, 02:00:31 AM »
This has been answered in another post from you yesterday.
It allows changing the EntryPoint from the IDE but you may need to set Yes (/NODEFAULTLIB). If you have C/C++ files in the project remove them to make all easy.

nidud

  • Member
  • *****
  • Posts: 1370
    • https://github.com/nidud/asmc
Re: setting the entry point in visual studio community 2017
« Reply #5 on: October 17, 2017, 02:13:58 AM »
It's also possible to define the entry point directly in the source code by adding end main:

Code: [Select]
.486
.model flat, c
.code

IntegerAdd proc
    ret
IntegerAdd endp

main proc
    call IntegerAdd
    ret
main endp

    end main

build:
Code: [Select]
ml -coff test.asm
or
Code: [Select]
ml -c -coff test.asm
link /subsystem:console test.obj

markallyn

  • Member
  • **
  • Posts: 63
Re: setting the entry point in visual studio community 2017
« Reply #6 on: October 17, 2017, 02:48:27 AM »
Hello everyone,

OK, I finally figured out how to use the VS IDE to set the entry point to one of my choosing.  Here's how to do it for those who don't know.  Go to the Solution Explorer.  Click on the project.  Go to the properties line and click it.  Go to the linker line.  Click it and then click "Advanced".  First line is the entry point option.  Go to the far right and you will see a small box with a downward pointing error.  Click it and it will give you an <Edit..> option.  Click it and a dialog box opens.  In the edit box type in whatever name you want as the entry point.  Then click OK.  Now the last step is absolutely crucial, and it is what I had not been doing.  After the dialog box closes you MUST hit the "enter" key.  Unless you do this, your entry point will not be saved.

Case closed.  But still, highly amusing.

Regards,
Mark