Error LNK1561: entry point must be defined

自作多情 提交于 2019-11-29 18:00:04

问题


I am working with Visual Studio 2012.

My Solution has 3 projects

projectA

projectB

projectC

and the Hierarchy is like

projectC depends on projectB which in turn depend on projectA. There is a main function in projectC and no main in projectB and projectA. The errors that i am getting are:

error LNK1561: entry point must be defined      projectA
error LNK1561: entry point must be defined      projectB

I have tried changing in the Configuration Properties -> Linker -> System -> SubSystem to Console (/SUBSYSTEM:CONSOLE) But the problem still persists

Help me out of this.


回答1:


It seems, that you misunderstand the term "module". There is no such C++ project in Visual Studio; C++ projects may be divided into three categories:

  • Programs - compilation produces an exe file, which may be executed;
  • Static libraries - compilation produces a lib file, which may be included in another project and are linked during the compilation;
  • Dynamic libraries - compilation produces a dll file, which may be attached to your program at run-time and provide additional functionality.

From your description, you want the projectB and projectC to be a static libraries, but instead you created them as executable files. Run the new project wizard again and choose "static library" instead of "Windows application".

You can read more about static libraries in the MSDN library.

If static libraries are too heavyweight for your application, you may simply include projectB and projectC files in your project (optionally take care of namespaces not to confuse the names of classes). It all depends on how much functionality you plan to implement in these "modules".




回答2:


set Properties -> Linker -> System -> SubSystem to "Windows (/SUBSYSTEM:WINDOWS)"




回答3:


What's happening possibly, what was happening with me, is that when you switch your properties of your project to .dll from .exe, if you switch from debug to release or from x86 to x64, each time you do that it's switching you back to .exe. Each configuration has it's own properties.

So, go to Properties > Configuration Type > .dll

If indeed you want to make a .dll.




回答4:


I'm going to guess you're using Windows for creating this project, for me, if I usually use SDL I get this error, all you have to do is type in this #include <Windows.h> that should fix it, if not then I'm not to sure how to fix that.



来源:https://stackoverflow.com/questions/17228301/error-lnk1561-entry-point-must-be-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!