Hi, I'm developing this project (http://www.tilengine.org/forum/showthread.php?tid=273) with Code::Blocks. (check out a gameplay video (https://www.youtube.com/watch?v=GXQ-a8ZHGaI) or this other discussion about it (https://rpgcodex.net/forums/threads/morgana-a-cutesy-lovecraftian-pixel-blobber.126753/) if you want more information. Or the project's Facebook page (https://www.facebook.com/morganadungeoncrawler)).
(https://i.ibb.co/4sRvyRk/def-augmentatx2.png)
I started programming it with pure modular C, Tilengine (http://www.tilengine.org/) for sprites & pixel art etc, SDL2 (https://www.libsdl.org/download-2.0.php) for mouse control, SDL2_mixer (https://www.libsdl.org/projects/SDL_mixer/) for audio (mp3 music and sound FX), SDL2_ttf (https://www.libsdl.org/projects/SDL_ttf/) for drawing text (including some Japanese characters), and SDL2 (https://www.libsdl.org/projects/SDL_image/) image (I don't remember why this one, but I used it somehow or somewhere).
So my general linker options look like this with GCC:
-lm -lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer -lSDL2_ttf -lSDL2_image
And a link to Tilengine.lib library:
(https://i.ibb.co/gWx2PgT/a.png)
Please notice this is for the topmost project options "Morgana". Below i have two target builds, one for GCC and one for CLANG. This one is for GCC:
(https://i.ibb.co/tpp0Zzr/b.png)
and the linking options vary a little from "Morgana" general linker options:
-lws2_32 -lSDL2main -lSDL2 -lSDL2_mixer -lSDL2_ttf -lSDL2_image
I rebooted the development of the project at some point and I'm migrating it to C++ OOP with Code::Blocks and GCC (and the same libraries mentioned). I plan to open source the project some day, and to do a Kickstarter for it, when I have a *MUCH* mature version and could dedicate all the time that this project needs (I have two little daughters).
Meanwhile I have a question. I use Code::Blocks and GCC for compiling without problems, but I want to use CLANG for its static analyzer and to check for more errors, but I have a linking problem. Besides I have no clue on how to trigger the CLANG analyzer. I used CppCheck integrated with Code::Blocks with no problems. I even change the Mingw used for one that uses posix threads for some thread I needed somewhere.
Well, my CLANG linking options are blank, so it uses the ones from "Morgana":
(https://i.ibb.co/xXQtwgg/c.png)
The compilation with GCC is successful:
(https://i.ibb.co/wS678fn/d.png)
But it fails with CLANG, since it cannot find m.lib
(https://i.ibb.co/K0z0ZkZ/e.png)
(cannot find m.lib in spanish)
LINK : fatal error LNK1181: no se puede abrir el archivo de entrada 'm.lib'
But if I remove -lm option then it doesn't compile with GCC. I also used the option "Use target options only" for CLANG build and blank linker options with Tilengine.lib linking at the side.
But then it says there is no entry point (no main). I don't know how to link SDL2 and the other libraries to CLANG. I think I installed them on top of LLVM CLANG directories as I did with MingW, but it doesn't work.
LINK : fatal error LNK1561: se debe definir el punto de entrada
Then I tried to add this options to CLANG linker:
-lm -lmingw32 -lSDL2main -lSDL2 -lSDL2_mixer -lSDL2_ttf -lSDL2_image
But then it says that cannot find SDL2main.lib linking error. ???
I don't understand why, where is that file? When you download SDL2 comes with no .lib files, just .a files and other stuff.
Sorry for the noobness :-[ :-[ :-[. I would like to fix the linking with CLANG as it worked with GCC, please can you help me or point me to some useful information?
Update. Now I tried adding this libraries:
C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\lib\libSDL2main.a C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\lib\libSDL2_mixer.a C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\lib\libSDL2_ttf.a C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\lib\libSDL2_image.a W:\Morgana\Tilengine.lib
(https://i.ibb.co/mSfPCVL/1.png)
It detects the libraries, but now it says it has NO entry point ("se debe definir el punto de entrada" is "you must define an entry point" (main) in spanish):
LINK : fatal error LNK1561: se debe definir el punto de entrada
clang++: error: linker command failed with exit code 1561 (use -v to see invocation)
Process terminated with status 1561 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Update 2.
Ok, using some help I added:
-Xlinker /subsystem:windows
(https://i.ibb.co/Kq6LxWz/2.png)
And now says machine type of library 'x64' is in conflict with the machine type of the destination 'x86'.
OMG OMG OMG I fixed it!
add this to main.cpp:
#undef main
int main(int argc, char *argv[]){ // Do not remove arguments or it will show a SDL_main error.
and linking options go like this:
-lSDL2main -lSDL2 -lSDL2_mixer -lSDL2_ttf -lSDL2_image -Xlinker /subsystem:console
And you must download SDL, SDL ttf, SDL image, etc... for developers Visual Studio version, and extract the .lib to the chocolatey installation folder where MingW64 is located.