Where is the main function [CMake build doesn't run]

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
nosba
Posts: 7
Joined: January 17th, 2016, 4:49 pm

Where is the main function [CMake build doesn't run]

Post by nosba »

Hi all,

I have downloaded the Wesnoth repository from git. I cannot find the main function

Code: Select all

int main (int argc, char **argv)
Which is the file that contains it?

I use Mac so It's not the one that is in wesnoth.cpp
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Where is the main function

Post by Tad_Carlucci »

$ grep -R wesnoth_main src
I forked real life and now I'm getting merge conflicts.
User avatar
Pentarctagon
Project Manager
Posts: 5496
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Where is the main function

Post by Pentarctagon »

Moved to Coder's Corner.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
nosba
Posts: 7
Joined: January 17th, 2016, 4:49 pm

Re: Where is the main function

Post by nosba »

Tad_Carlucci wrote:$ grep -R wesnoth_main src
ok but the program needs a main. If the main is the one in SDLmain.mm it does not work with cmake. the wesnoth_main function is never called.
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Where is the main function

Post by Tad_Carlucci »

I don't use MacOS so haven't done it but I know that Wesnoth compiles and runs on MacOS.

Are you code-reading or actually compiling and saying you're not compiling correctly? If you're code-reading, you need to study how MacOS and SDL start up applications. If you're having problems compiling, I'd suggest asking more specific questions. Here is fine, but you might have better luck asking on the developer channels IRC or Discord.

I see the startup:

[NSBundle loadNibNamed:@"SDLMain" owner:NSApp];
[NSApp run];
I forked real life and now I'm getting merge conflicts.
nosba
Posts: 7
Joined: January 17th, 2016, 4:49 pm

Re: Where is the main function

Post by nosba »

Tad_Carlucci wrote:I don't use MacOS so haven't done it but I know that Wesnoth compiles and runs on MacOS.

Are you code-reading or actually compiling and saying you're not compiling correctly? If you're code-reading, you need to study how MacOS and SDL start up applications. If you're having problems compiling, I'd suggest asking more specific questions. Here is fine, but you might have better luck asking on the developer channels IRC or Discord.

I see the startup:

[NSBundle loadNibNamed:@"SDLMain" owner:NSApp];
[NSApp run];
I know that wesnoth compiles on macOS. The problem is with cmake only. If I use scons it works perfectly. I think that some files are missing from CmakeList.txt in src and I'm trying to fix it.
Thanks for the advices I'll try with discord and IRC.
User avatar
singalen
iOS Port Maintainer
Posts: 314
Joined: January 3rd, 2007, 10:18 am
Location: bay

Re: Where is the main function

Post by singalen »

CMake's file organization is a bit different.
The fastest hack to make it work is to go to wesnoth.cpp and replace

Code: Select all

#ifdef __APPLE__
extern "C" int wesnoth_main(int argc, char** argv);
int wesnoth_main(int argc, char** argv)
#else
int main(int argc, char** argv)
#endif
with

Code: Select all

#if 0
extern "C" int wesnoth_main(int argc, char** argv);
int wesnoth_main(int argc, char** argv)
#else
int main(int argc, char** argv)
#endif
I believe it's a glitch and need s to be fixed some day.
Post Reply