How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Get help with compiling or installing the game, and discuss announcements of new official releases.

Moderator: Forum Moderators

Locked
the_wanderer
Posts: 3
Joined: April 4th, 2010, 5:41 am

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by the_wanderer »

Ok, I tried to building wesnoth 1.8.1 with code::Blocks it compiled fine, but i got the following errors during the linking process. :augh:

Linking executable: ..\..\wesnoth.exe
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text+0x1669): undefined reference to `mp::lobby::lobby(game_display&, config const&, mp::chat&, config&)'
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text$_ZN2mp11gamebrowserD1Ev[mp::gamebrowser::~gamebrowser()]+0x14): undefined reference to `vtable for mp::gamebrowser'
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text$_ZN2mp5lobbyD1Ev[mp::lobby::~lobby()]+0xe): undefined reference to `vtable for mp::lobby'
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text$_ZN2mp5lobbyD1Ev[mp::lobby::~lobby()]+0x1b): undefined reference to `vtable for mp::lobby'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 12 seconds)
4 errors, 0 warnings

Please help me solve this problem
User avatar
McShark
Posts: 76
Joined: March 19th, 2008, 10:41 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by McShark »

I've just updated the project files and did a "build project" with them. Worked fine (after changing one file). Changed files are commited. Just update SVN and try builiding again. If it doesn't work try to rebuild the whole project.

Edit: I just have seen that you try to build the version 1.8.1. Where did you get the sources from (I guess from the download page), where did you get the C::B project files (I guess from SVN Tag 1.8.1)?

McShark
the_wanderer
Posts: 3
Joined: April 4th, 2010, 5:41 am

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by the_wanderer »

My source is actually a patched 1.8 tarball (using xdelta)from the downlaod page. the C::B project file was already present in it.
btw, I had to do a bit of tweaking in the project files as they pointed to some nonexistent files(namely teleport.cpp/hpp for wesnoth and time.cpp/hpp for wesnothd)
User avatar
McShark
Posts: 76
Joined: March 19th, 2008, 10:41 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by McShark »

OK, I think you have to add some other files in this case. You can try to do that by using context menu on Sources->src and use "Add files recursively", choosing the src-folder, using wildcard *.cpp (leaving out src/campaign_server/* and src/loadscreen_empty.cpp and src/server/* and src/tests/* and src/tools/*).

McShark
Last edited by McShark on May 21st, 2010, 6:41 pm, edited 1 time in total.
User avatar
governor
Posts: 267
Joined: December 8th, 2006, 12:32 am

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by governor »

Successfully compiled today (May 20 2010) using the codeblocks instructions beginning on page 4 of this thread and ending with Crab's instructions:
Crab wrote:Successfully compiled using CodeBlocks today. Needed to:
1) use instructions from here, used libs (std package and lua package) from here
2) grab fontconfig library, using binary from http://www.gtk.org/download-windows.html
3) rename a few libs (add version suffix)
4) grab intl.dll from wesnoth distribution
5) fix a few stale files in project (already committed the changes to project file)
Step 2 elaboration:
I just downloaded the dev package rather than the binaries and moved the corresponding lib and include contents to the lib and include folders of CodeBlocks. This step was most likely unnecessary, I did not have any dependency issues corresponding to fontconfig. Also pango libraries are included in McShark's IDE_files.

Step 3 elaboration:
(renamed libs in CodeBlocks\lib\)
1) libpango.a to libpango-1.0.a
2) libpangocairo.a to libpangocairo-1.0.a
3) libglib.a to libglib-2.0.a

In addition grabbed lua5.1.dll from wesnoth 1.8.0 release and renamed to lua51.dll, moved this to root directory of the svn co. Probably could have renamed the lib in codeblocks project file, but did not want to make this change since I think McShark is maintaining the cbp.

At this time no need for step 5.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by Anonymissimus »

I seem to have compiled wesnoth 1.8.1 successfully yesterday with Code::Blocks on win XP, for the first time. I'm just quoting & writing the things I did here as long as memory is still fresh (hopefully it's all...)

-Took source including Code::Blocks project file from download page, version 1.8.1
BroodKiller wrote:2)Download CodeBlocks 8.02 without MinGW from here:
http://www.codeblocks.org/downloads/binaries

Install it anywhere you want ("C:\Program Files\CodeBlocks" by default). Don't use the MinGW that comes bundled with CodeBlocks because it won't link properly (at least with the lib package used here).

3)Download the prepared lib package (about 27 MB). Extract the files from the "IDE_files" directory to your CodeBlocks installation directory. Extract the files from the "Wesnoth_libs" directory to where you have downloaded the Wesnoth source.
http://fourierdreams.com.ar/downloads/weswin.rar

This is basically just an updated version of the McShark's Dev-Cpp pack.

4)Run CodeBlocks, and go to Settings->"Compiler and Debugger"->"Global compiler settings". Make sure the "Selected Compiler" is the GNU GCC Compiler and go to the "Toolchain executables" tab.

If it isn't already, change the "Compiler's installation directory" to your CodeBlocks installation directory (and NOT its "/bin" subdir for example). Also change the names of the C compiler (gcc), C++ compiler (g++) and the Linker for dynamic libs (g++) by adding a "-dw2" at the end. You should have "mingw32-gcc-dw2.exe" and "mingw32-g++-dw2.exe".

5)Go to the "Search directories" tab and add "Your-Codeblocks-path\include" to the Compiler ("C:\Program Files\CodeBlocks\include" by default) and "Your-Codeblocks-path\lib" to Linker ("C:\Program Files\CodeBlocks\lib" by default).
-Took lua-related files (when the errors appeared) and instructions from
McShark wrote:Download lua binaries and includes and unpack content of includes to your includes-folder, the two dlls into wesnoth folder and the two lib-files to your lib-folder.
governor wrote:
Crab wrote: 2) grab fontconfig library, using binary from http://www.gtk.org/download-windows.html
3) rename a few libs (add version suffix)
4) grab intl.dll from wesnoth distribution
Step 2 elaboration:
I just downloaded the dev package rather than the binaries and moved the corresponding lib and include contents to the lib and include folders of CodeBlocks. This step was most likely unnecessary, I did not have any dependency issues corresponding to fontconfig.
No, got an error about missing fontconfig. The file wanted is called Fontconfig and at the bottom of the page under "Third Party Dependencies" (because I donwloaded various other stuff from there until realizing this^^)
Step 3 elaboration:
(renamed libs in CodeBlocks\lib\)
1) libpango.a to libpango-1.0.a
2) libpangocairo.a to libpangocairo-1.0.a
3) libglib.a to libglib-2.0.a
-Got the same error like the_wanderer:
the_wanderer wrote:Ok, I tried to building wesnoth 1.8.1 with code::Blocks it compiled fine, but i got the following errors during the linking process. :augh:

Linking executable: ..\..\wesnoth.exe
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text+0x1669): undefined reference to `mp::lobby::lobby(game_display&, config const&, mp::chat&, config&)'
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text$_ZN2mp11gamebrowserD1Ev[mp::gamebrowser::~gamebrowser()]+0x14): undefined reference to `vtable for mp::gamebrowser'
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text$_ZN2mp5lobbyD1Ev[mp::lobby::~lobby()]+0xe): undefined reference to `vtable for mp::lobby'
.objs-release\src\multiplayer.o:multiplayer.cpp:(.text$_ZN2mp5lobbyD1Ev[mp::lobby::~lobby()]+0x1b): undefined reference to `vtable for mp::lobby'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 12 seconds)
4 errors, 0 warnings
Did MacSharks suggestion
McShark wrote:OK, I think you have to add some other files in this case. You can try to do that by using context menu on Sources->src and use "Add files recursively", choosing the src-folder, using wildcard *.cpp (leaving out src/campaign_server/* and src/loadscreen_empty.cpp and src/server/* and src/tests/* and src/tools/*).
by adding everything first and then removing the folders I should leave out, because this "add files" thing is tough to handle. It seems that in the end there were two files added, namely IIRC
multiplayer.cpp and
boilerplate-header.cpp
-------------------------------------
The whole thing went a lot better than I would have expected, especially since I hardly have any clue about what I did, although it's not the first C++ program I've compiled. Obviously most of the job in setting up how to compile is done by the project file wesnoth.cbp.
wesnoth.exe seems to run fine, except for that I can't change the language (the language files are missing I'm guessing.)
Didn't care about wesnothd.cbp, would it crash if I tried the mutiplayer stuff then ? I don't use it anyway for now.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
orondf
Posts: 17
Joined: November 20th, 2009, 12:52 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by orondf »

Hi All,
I tried to compile the latest svn (rev 43620 20-06-10) on Code::Blocks 8.02 on XP, and received the following errors and warnings:

Compiling: ..\..\src\marked-up_text.cpp
F:\WesnothSVN\wesnoth\src\marked-up_text.cpp: In function 'bool font::is_cjk_char(wchar_t)':
F:\WesnothSVN\wesnoth\src\marked-up_text.cpp:273: warning: comparison is always false due to limited range of data type
F:\WesnothSVN\wesnoth\src\marked-up_text.cpp:273: warning: comparison is always true due to limited range of data type

Compiling: ..\..\src\text.cpp
F:\WesnothSVN\wesnoth\src\text.cpp:555: warning: 'void font::decode_pixel(unsigned char*)' defined but not used

Linking executable: ..\..\wesnoth.exe
.objs-release\src\display.o:display.cpp:(.text+0x3322): undefined reference to `arrow::get_path() const'
.objs-release\src\display.o:display.cpp:(.text+0x34e6): undefined reference to `arrow::get_path() const'
.objs-release\src\display.o:display.cpp:(.text+0x367a): undefined reference to `arrow::get_previous_path() const'
.objs-release\src\display.o:display.cpp:(.text+0x37ec): undefined reference to `arrow::get_path() const'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x3f7a): undefined reference to `wb::manager::has_action(unit const&) const'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x40ae): undefined reference to `wb::manager::select_unit(unit&)'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x417d): undefined reference to `wb::manager::erase_temp_move()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x418a): undefined reference to `wb::manager::deselect_unit()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x4249): undefined reference to `wb::manager::apply_temp_modifiers()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x4269): undefined reference to `wb::manager::remove_temp_modifiers()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x51a4): undefined reference to `wb::manager::save_temp_move()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x63c2): undefined reference to `wb::manager::remove_highlight()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x63d3): undefined reference to `wb::manager::highlight_hex(map_location const&)'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x7063): undefined reference to `wb::manager::create_temp_move(std::vector<map_location, std::allocator<map_location> > const&)'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x1443): undefined reference to `wb::manager::manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x146b): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xb34d): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xb5ca): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xc681): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xc8fe): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xcca9): more undefined references to `wb::manager::~manager()' follow
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x1a4): undefined reference to `wb::manager::execute_next()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x75a): undefined reference to `wb::manager::delete_last()'
.objs-release\src\team.o:team.cpp:(.text+0xa640): undefined reference to `wb::side_actions::side_actions()'
.objs-release\src\team.o:team.cpp:(.text+0xb344): undefined reference to `wb::side_actions::side_actions()'
collect2: ld returned 1 exit status
Process terminated with status 1 (57 minutes, 34 seconds)
24 errors, 3 warnings

Does anyone know what is wrong?
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by AI »

orondf wrote:Hi All,
I tried to compile the latest svn (rev 43620 20-06-10) on Code::Blocks 8.02 on XP, and received the following errors and warnings:

Compiling: ..\..\src\marked-up_text.cpp
F:\WesnothSVN\wesnoth\src\marked-up_text.cpp: In function 'bool font::is_cjk_char(wchar_t)':
F:\WesnothSVN\wesnoth\src\marked-up_text.cpp:273: warning: comparison is always false due to limited range of data type
F:\WesnothSVN\wesnoth\src\marked-up_text.cpp:273: warning: comparison is always true due to limited range of data type
This is due to wchar_t being defined only 16 bits wide on windows, meaning characters above U+D7FF cannot be represented in a single character and thus cannot be tested this way.
Compiling: ..\..\src\text.cpp
F:\WesnothSVN\wesnoth\src\text.cpp:555: warning: 'void font::decode_pixel(unsigned char*)' defined but not used
This sounds like a valid issue that needs to be looked at.
Linking executable: ..\..\wesnoth.exe
.objs-release\src\display.o:display.cpp:(.text+0x3322): undefined reference to `arrow::get_path() const'
.objs-release\src\display.o:display.cpp:(.text+0x34e6): undefined reference to `arrow::get_path() const'
.objs-release\src\display.o:display.cpp:(.text+0x367a): undefined reference to `arrow::get_previous_path() const'
.objs-release\src\display.o:display.cpp:(.text+0x37ec): undefined reference to `arrow::get_path() const'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x3f7a): undefined reference to `wb::manager::has_action(unit const&) const'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x40ae): undefined reference to `wb::manager::select_unit(unit&)'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x417d): undefined reference to `wb::manager::erase_temp_move()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x418a): undefined reference to `wb::manager::deselect_unit()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x4249): undefined reference to `wb::manager::apply_temp_modifiers()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x4269): undefined reference to `wb::manager::remove_temp_modifiers()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x51a4): undefined reference to `wb::manager::save_temp_move()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x63c2): undefined reference to `wb::manager::remove_highlight()'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x63d3): undefined reference to `wb::manager::highlight_hex(map_location const&)'
.objs-release\src\mouse_events.o:mouse_events.cpp:(.text+0x7063): undefined reference to `wb::manager::create_temp_move(std::vector<map_location, std::allocator<map_location> > const&)'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x1443): undefined reference to `wb::manager::manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x146b): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xb34d): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xb5ca): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xc681): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xc8fe): undefined reference to `wb::manager::~manager()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0xcca9): more undefined references to `wb::manager::~manager()' follow
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x1a4): undefined reference to `wb::manager::execute_next()'
.objs-release\src\play_controller.o:play_controller.cpp:(.text+0x75a): undefined reference to `wb::manager::delete_last()'
.objs-release\src\team.o:team.cpp:(.text+0xa640): undefined reference to `wb::side_actions::side_actions()'
.objs-release\src\team.o:team.cpp:(.text+0xb344): undefined reference to `wb::side_actions::side_actions()'
collect2: ld returned 1 exit status
Process terminated with status 1 (57 minutes, 34 seconds)
24 errors, 3 warnings

Does anyone know what is wrong?
This means the Code::Blocks projectfiles haven't been updated yet since new source files have been added. I have just added the whiteboard files. If there are any other linking issues, you can try to fix it by finding the other missing files.
orondf
Posts: 17
Joined: November 20th, 2009, 12:52 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by orondf »

Hi,
I have located the problem - it is that the arrow.cpp file is missing from the project. (after updating from SVN server)
Thanks for the help.
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by AI »

I've added arrow.cpp to the project.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Blocks

Post by Anonymissimus »

compiled trunk with CodeBlocks 10.05
In addition to the stuff I mentioned in my last post needed to add
persist_manager.cpp
and rename
libgobject.a -> libgobject-2.0.a
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
orondf
Posts: 17
Joined: November 20th, 2009, 12:52 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Bl

Post by orondf »

Hi,
I tried to compile the latest SVN and received 50 errors.
All of them are like "undefined reference to `lua_tointeger(lua_State*, int)'" in src/ai/lua/core.cpp.
This has been happening ever since the src/lua folder has been added, even if I add it to the projectfile.
Does anyone knowe why this is happening?
P.S.: I have attached all the errors.
Attachments
errors_full.txt
(5.72 KiB) Downloaded 772 times
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Bl

Post by Anonymissimus »

Try creating a new project including all the lua files, compiling to a static lib ...\projectfiles\CodeBlocks\liblua.a and reference that libary for the wesnoth project. (I got it to build that way.)
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Bl

Post by AI »

I've applied Anonymissimus's patch, so stuff should work again now.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: How to compile Wesnoth on Windows with Dev-Cpp, Code::Bl

Post by Anonymissimus »

Not quite. You probably still need to add \projectfiles\CodeBlocks\ to the search directories (gobal compiler settings>search directories>linker) Don't know how to add it so that it belongs to the project file and is system-independent...
Let me know whether it worked for you.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Locked