• Register
1 vote
51 views

Problem:

Hello Kodlogs,

I hope all of you are doing well. Just now I’ve installed MS Visual Studio to run a C++ program. I’ve downloaded a C++ program from the internet and paste the code inside the VS console. The same program worked in Eclipse but it doesn’t in VS. Here is the downloaded code snippet:

#include "SDL_Net.h"
void main(){
    SDL_Init(1);
	SDLNet_Init();
	IPaddress ip;
	TCPsocket tcpsock;
	 if(SDLNet_ResolveHost(&ip,NULL,9999)==-1){
	     printf("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
	     exit(1);
	 }
	 tcpsock=SDLNet_TCP_Open(&ip);
	 if(!tcpsock){
	     printf("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
	     exit(2);
	     }
	     SDL_Quit();
	     SDLNet_Quit();
	     return;
}

And I am getting this output:

>------ Build started: Project: server, Configuration: Debug Win32 ------
	1>Linking...
	1>LINK : fatal error LNK1561: entry point must be defined
	1>server - 1 error(s), 0 warning(s)
	========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I’ve searched for the solution over the internet for the last 30 minutes and I got nothing except one solution that said to add a main() function which I did already. I found this forum very active and helpful. Could you guys save my day? Thanks a lot.

12 7 7
15,250 points

Please log in or register to answer this question.

2 Answers

1 vote

Solution:

First of all, void main() is always wrong in C++. Replace it with int main() and the SDL library requires a parameterized int main() function. So, add

int main(int argc, char *argv[])

at the top of your program instead of a void main() function. If the program still doesn’t work that means something wrong with your project settings. You may create a win32 project instead of a console. To fix the problem, either, Right-click on project namePropertiesExpand Linker tabSystemSubSystem: make sure that it is Console (/SUBSYSTEM: CONSOLE) Or create your project again. This could save your day. Complete all the steps and leave your comment here if it doesn’t work for your case. I’ll have a look again.

Thanks.

 

13 9 6
94,260 points
0 votes

Solution:

 Win32 and similar project, the entry point is WinMain().

  1. Right-click on the Project (not the reSolution) on the left side.

  2. Then click on Properties -> Configuration Properties -> Linker -> System

In case it tells Subsystem Windows your entry point must be WinMain(), for example

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
   your code here ...
}

Furthermore, speaking of the comments. This is a compile (or more rightly a Link) error, not a run-time error. At the time you begin to debug, the compiler requires to make a complete program (not only to compile your module) and that is when the error happens.

It does not yet get to the point being loaded and run.

It cant trace the entry point for your program, in this instance main(). Your linker settings are perhaps incorrect.

In my instance, the program was running fine, however after one day, I only ran into this issue without doing anything…

The solution was to manually include 'Main' as the Entry Point (prior editing, the area was empty):

Alter it to Console (/SUBSYSTEM:CONSOLE) it will perform

Ensure to double check your "Active Configuration" (Debug / Release), to view in case you are really building a DLL.

In case project is made as Win32 Project this linker option will be automaticly fixed:

File – New Project . – Visual C++ – Win32 – Win32 Project

In case projec is made as General Empty Project this linker option requires to be manually included:

RC on ProjectName – Properties – Configuration Properties – Linker – Coommand Line

More Options: /SUBSYSTEM:WINDOWS

10 6 4
31,120 points

Related questions

0 votes
1 answer 5 views
5 views
Problem How to fix this error: entry point must be definedin c++
asked Apr 13 Subhendu 4.5k points
0 votes
2 answers 938 views
938 views
Problem : I am unable to figure out what is wrong with my code. When I try to compile my code I get the below message: “Program does not contain a static 'main' method suitable for an entry point”
asked Jan 29, 2020 jwilliam 3.9k points
0 votes
1 answer 13 views
13 views
Problem: Does anyone know the solution of it? So kindly let me know ..the procedure entry point _except1 could not be located
asked Apr 21 Ifra 37.2k points
1 vote
1 answer 7 views
7 views
Problem: Can someone please help fix this: the activity must be exported or contain an intent-filter. visual studio entry point must be defined
asked Mar 11 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 3 views
3 views
Problem: Try to discover this >The procedure entry point could not be located kernel32 dll
asked May 9 Chi Omega 21.8k points
0 votes
1 answer 4 views
4 views
Problem: My C++ application fails to launch on a Windows 2008 SP2 machine with the following error.My-Application.exe - Entry Point Not Found. The procedure entry point K32EnumProcessModules could not be located in the dynamic link library KERNEL32.dll.Any idea how can I know which part of my application is consuming this module that is causing the issue?
asked May 2 sumaiya simi 43.9k points
1 vote
1 answer 4 views
4 views
Problem: When I try to run VS2008 FeaturePack I get this error : the procedure entry point ?_Xmem@tr1@std@@YAXXZ could not be located in the dynamic link library MSVCP90D.dll. How can I solve this ?
asked May 2 Raj Tyagi 15.6k points
1 vote
1 answer 6 views
6 views
Problem: I keep getting this error whenever I try to run my Irrlicht C++ Console Application in Windows:: the procedure entry point __gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll I have been using CodeBlocks v12.11 with MinGW and the Irrlicht v1.8 engine. How can I solve this problem?
asked Apr 26 Raj Tyagi 15.6k points
0 votes
1 answer 3 views
3 views
Problem: I compiled a program with Crypto++ and boost when I try to start it I get the error message below. CryptAcquireContextA is used by Crypto++ and boost. The procedure entry point CryptAcquireContextA could not be located in the dynamic link library C:\myexe ... . I just noticed WinFsp is also using CryptAcquireContextA so the issue may be in WinFsp. Maybe it is not compatible with mingw?
asked Apr 25 Yeamin 22k points
0 votes
1 answer 5 views
5 views
Problem: Can someone please help fix this > The procedure entry point __gxx_personality_v0 could not be located in the dynamic link library
asked Apr 23 ummeshani 10.8k points