ChessPlusPlus

Pages: 12345
Thanks, I'll have to try that when I get home.
Script Coder wrote:
Try adding the following flag to your compile
I only said that like 15 times on IRC... Lol!
Nope, here is the exact output from the console:

(edit) https://gist.github.com/LB--/5447436
Last edited on
I'm in the same boat at this point.
Well at least the code can compile for you. I really don't see why it doesn't link, it's just so frustrating. What's even more annoying is the large number of people that use SFML with clang as if it's obvious and easy to do. What are we doing wrong?
I was just able to compile and link statically (dynamically has been working no problem ) with this command
clang++ -Wall -std=c++11 -D_DEBUG -DSFML_STATIC -I../../lib/json-parser/ -L/usr/local/lib -o 
../../bin/chesspp  Application.cpp AppStateGame.cpp graphics/Graphics.cpp ../Main.cpp 
../../lib/json-parser/json.c log/Logger.cpp board/Bishop.cpp board/Board.cpp board/King.cpp 
board/Knight.cpp board/Pawn.cpp board/Piece.cpp board/Position.cpp board/Queen.cpp board/Rook.cpp 
-lsfml-system-s-d -lsfml-graphics -lsfml-window-s-d


Note the order I'm linking sfml, it matters. Unfortunately I get a runtime error
Error: Error loading JSON: 1:0: Unexpected 
Caught in main: Segmentation fault

I also didn't need to re-compile SFML with clang, the GCC libs worked for me.
Last edited on
master branch https://github.com/naraku9333/ChessPlusPlus
error: ../../lib/json-parser/json.c: No such file or directory


Get it from https://github.com/udp/json-parser.git

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
In file included from Application.cpp:1:
In file included from ./Application.hpp:4:
In file included from ./AppState.hpp:24:
In file included from ./AppStateGame.hpp:5:
In file included from ./graphics/Graphics.hpp:6:
./graphics/../config/Configuration.hpp:20:10: fatal error: '../log/logger.hpp' file not found
#include "../log/logger.hpp"
         ^
1 error generated.
There is a `Logger.hpp', however I suggest you to avoid those directory dependent includes and instead do simply #include "log/logger.hpp" compiling with `-I dir'

Also, ¿may you create a makefile? (LowestOne and Thumper seem to work with another directory structure, also Thumper doesn't create *.o)
json-parser is included as a submodule. I've contacted GitHub and they have no plans to include submodules in ZIP downloads (if you cloned from the coomandlin with git you have to init the submodules).

Ah, I thought I fixed all the case-sensitive problems.

Thanks for the advice on `-I dir`, will definitely do that.

As for a makefile, I need to learn how to make those. The batch file is for Windows users, wherease makefiles are generally hard to deal with on Windows. I'll have to research them (or modify the existing makefiles the best I can).

EDIT: If the library order is important, then I'm going to facepalm. That seems really annoyingly stupid - oh well.

I do have a request though: please stop accepting my PRs if they don't compile for you :p

As this is my mess, I'll clean it up. Still though...please verify that my changes work!

EDIT: Changes didn't help:
https://gist.github.com/LB--/5447436
Last edited on
Linking dynamically brings it down to one linker error:

C:/Users/Nicholas/AppData/Local/Temp/Application-442877.o:fake:(.text+0x12b): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'


Which pretty closely matches that SO question. I don't know how naraku built it though - I am using the same libs he is.
In what order are you linking the sfml libs?
I'm using this one:
https://github.com/LB--/ChessPlusPlus/blob/test-ne555/build_clang_win.bat
ne555 said the order only mattered if you link statically, so I tried linking dynamically and got that one linker error. He had me check to see if that symbol actually is in graphics.lib and it is, but this problem looks suspiciously like that SO question.

How have you been able to compile? I am using the same SFML 2.0 GCC libs as you.
Well, I just realized it only compiled for me statically because I had a typo and linked sfml-graphics dynamically
clang++ -Wall -std=c++11 -D_DEBUG -DSFML_STATIC -I../../lib/json-parser/ -L/usr/local/lib -o 
../../bin/chesspp  Application.cpp AppStateGame.cpp graphics/Graphics.cpp ../Main.cpp 
../../lib/json-parser/json.c log/Logger.cpp board/Bishop.cpp board/Board.cpp board/King.cpp 
board/Knight.cpp board/Pawn.cpp board/Piece.cpp board/Position.cpp board/Queen.cpp board/Rook.cpp 
-lsfml-system-s-d -lsfml-graphics -lsfml-window-s-d


LB wrote:
How have you been able to compile?
Yes on linux, I haven't had a chance to test on windows yet.
I am able to compile on linux as well. ne555 has worked a nice makefile out for that (which is now in naraku's repo).

Working on making it compile on OS x now.
Apparently my post failed to submit.

@naraku I've tried that order with and without -s and -s-d on each one (I did notice that you didn't statically link graphics) but the best case scenario is all the libs with dynamic linking and one linker error.

Personally I don't need to be able to compile statically because I'm not responsabile for generating distributions for each version.

We really need to solve the compiling problem - we don't even know if the game runs as intended right now (or if it crashes or not).
It does run without crashing. We know this because we've been able to link SFML and run on linux distros.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff70a852a in __dynamic_cast () from /usr/lib/libstdc++.so.6
(gdb) bt
#0  0x00007ffff70a852a in __dynamic_cast () from /usr/lib/libstdc++.so.6
#1  0x0000000000408a81 in chesspp::Exception::operator== (this=0x7a49b0, other=...) at src/Exception.hpp:33
#2  0x0000000000407cad in chesspp::operator== (e1=..., e2=...) at src/Exception.hpp:37
#3  0x0000000000407d8e in chesspp::Exception::fullMessage (this=0x7a49b0) at src/Exception.hpp:55
#4  0x0000000000407b49 in main () at src/Main.cpp:13
@ne555 I don't know what could cause a segfault in dynamic cast like that, do you have any idea to help me with tacking the issue? I've followed that call stack and I'm not sure what causes the crash.

Can you get a call stack for the stack unwind when the exception is thrown?
$ gdb ./bin.debug/chesscpp.bin
#0  chesspp::Exception::Exception (this=0x7fffffffd4b0, e="") at src/Exception.hpp:20
#1  0x000000000040e780 in chesspp::util::JsonReader::JsonReader (this=0x7fffffffded8,
    s=...) at src/util/JsonReader.hpp:29
#2  0x000000000040e5bd in chesspp::util::JsonReader::JsonReader (this=0x7fffffffded8,
    s=...) at src/util/JsonReader.hpp:31
#3  0x000000000040e58d in chesspp::util::JsonReader::JsonReader(<unknown type in ChessPlusPlus/bin.debug/chesscpp.bin, CU 0x48f1f, DIE 0x6076f>) (this=0x7fffffffded8,
    s=<unknown type in ChessPlusPlus/bin.debug/chesscpp.bin, CU 0x48f1f, DIE 0x6076f>) at src/util/JsonReader.hpp:33
#4  0x000000000040df47 in chesspp::config::Configuration::Configuration (
    this=0x7fffffffdec8, configFile="config.json") at src/config/Configuration.hpp:72
#5  0x000000000040f2b2 in chesspp::config::BoardConfig::BoardConfig (this=0x7fffffffdec8)
    at src/config/Configuration.hpp:95
#6  0x0000000000409f65 in chesspp::config::BoardConfig::BoardConfig (this=0x7fffffffdec8)
    at src/config/Configuration.hpp:96
#7  0x00000000004095d2 in chesspp::graphics::GraphicsHandler::GraphicsHandler (
    this=0x5a83b0, _display=0x7fffffffe0b0) at src/graphics/Graphics.cpp:11
#8  0x00000000004106b2 in chesspp::AppStateGame::AppStateGame (this=0x5a8390,
    _app=0x7fffffffe0b0, _display=0x7fffffffe0b0) at src/AppStateGame.cpp:9
#9  0x000000000040f943 in chesspp::Application::Application (this=0x7fffffffe0b0)
    at src/Application.cpp:10
#10 0x0000000000408ebe in main () at src/Main.cpp:9
I'm having a hard time reproducing the crash. Can you tell me if the app crashes or exits cleanly and what ends up in debug_log.log with this code?
https://github.com/LB--/ChessPlusPlus/commit/test-crash
ne555's issue has been resolved, it was a really stupid mistake I made with passing temporaries. It has been resolved in LB--/lb-refactor
Pages: 12345