Programming Help: How To Compile And Run lem3edit (V1.0)

Started by Nessy, January 08, 2018, 10:22:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nessy

Hi!

So one of my New Year's Resolutions was to make a serious return to programming, but start going beyond just printing stuff to a console. To do this I have decided to follow kieranmillar and clone lem3edit on GitHub to play around with the source code of this Lemmings 3 level editor. It's a bit more of a gentle project to at least start with than some other stuff I tried.

However, despite following this tutorial on how to set up SDL2 on my computer exactly, I can't seem to compile and run the current version of lem3edit (V1.0).

I run the following in the command prompt:

g++ lem3edit.cpp -IC:\Development\SDL2\include\SDL2  -LC:\Development\SDL2\lib -IC:\Development\SDL_ttf\include\SDL2 -LC:\Development\SDL_ttf\lib -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o lem3edit

But I continue to get the errors that are in the image attached below.

I'm using mingw and have placed the necessary files into the bin folder of mingw, mingw is in my environmental variable paths, and I'm in the correct directories.

I'm still a huge newbie at this so I'm probably doing something really stupid or something considered bad practice. That's okay, I just want to see what others think so that I can start learning (and start this project too :P)

Thank you so much!

kieranmillar

So looking at that screenshot the compiler is tripping up over every single function call that the file lem3edit.cpp calls that comes from another file except those from SDL2. It's also tripping up over SDL_tff.

I guess this is because your command line says to compile lem3edit.cpp, but that's the only file it's actually trying to compile? I've not used g++, but there must be someway to link the entire project at once without typing out the name of every single file.

Simon

You have linker errors because the compiled code calls functions that aren't in the compiled code nor in any of the libraries. It looks like they're in other parts of lem3edit.

Name all of the project's .cpp files on the command line instead of just lem3edit.cpp. Also add -lSDL2_ttf as Kieran said.

This is not an ideal long-term solution because you'll build the entire project every time, which is uncommon for C and C++ projects. You would rather build only the .cpp files that need to be rebuilt, then link everything. In the long term, it would be nice if Kieran provided a Makefile, CMake files, have another build system, or at least give build instructions. :lix-wink:

-Ipath adds path for header lookup during compilation.
-Lpath adds path for library lookup during subsequent -l agruments.
-lmylib links to libmylib.

-- Simon

kieranmillar

Quote from: Simon on January 08, 2018, 10:44:33 PMIn the long term, it would be nice if Kieran provided a Makefile, CMake files, have another build system, or at least give build instructions. :lix-wink:

That sounds great! But here's where we run into a problem with me also being an amateur programmer: I have no idea what anything you just said means :lix-winktongue:

I just made a new project in Visual Studio and added in all of the files one at a time. :lix-dead:

Simon

CMake is a platform-independent system that, depending on platform or desired IDE, can produce Makefiles, Visual Studio projects, ..., that will then build from code using your favorite native build system.

make is ubiquitous on Linux, it builds according to instructions in Makefiles. CMake is more complicated than writing a quick-and-dirty Makefile, but writing good Makefiles by hand is nasty.

-- Simon

Nessy