Source code section

Pages: 12
Source code of fully-functional programs made available through this website by our users.

Coming soon


Should we, uhh, code something?
It's been coming soon for a while. Do you thing twicker is waiting for us?
I brought this up awhile ago, and twicker actually responded. He said there is now a source code section in the articles, and if that gets enough postings he'll open up the source code section of the site.
I'm thinking about educational, simplified, command line utilities, written in self-sufficient C++11, and with Doxygen comments.

Pipe dream.
I'll do some if you help me come up with ideas. Writing trivial programs with too many comments is kind of my speciality.
I'm in so long as the code is open source without restrictions. I suppose that would mean that the code is not GPL compatible, which is a very good thing in my opinion.
I just tried adding a source code article for an animated checkers game I made in SFML. It's fairly cool.

It kept disappearing when I hit "submit" though, so I gave up.
(15 second pause then it comes back blank ).

Too bad, I have an animated card game (Rummy) which is player vs. computer, and the computer plays fairly well! It would have been next.

EDIT:
The article submits fine without any files attached, but then the article is completely pointless.
It says .zip is an allowed extension...

OK. I can attach other file types. It's choking on the .zip file (9Mb)

Help please!
Last edited on
I'm in so long as the code is open source without restrictions. I suppose that would mean that the code is not GPL compatible, which is a very good thing in my opinion.

Expat MIT license?

I'll do some if you help me come up with ideas. Writing trivial programs with too many comments is kind of my speciality.

Write a program that flips all the bits in a file, demonstrating how to use stream iterators, std::transform() and lambda functions.
For simplicity, I suggest that the arguments be:
program.exe inputFile outputFile

@fun2code: use github
¿why does it weight so much?
@ne555.
It's the dll-s.
sfml-graphics.dll = 5Mb alone.

A zip folder containing everything except the 5 dlls (all source code + exe + images ) weighs in at 137kb.
The program won't run without the dlls.

I'll look into github. Thanks.

EDIT: I published and included a zip file without the 5 dlls. The 137kb .zip file uploaded no problem.
I left a list of the names of the 5 missing files and instructed readers to download these themselves at sfml.org. This will have to do for now.

I also published the rummy card game. The computer plays well enough that you have to make an effort to beat it. If you play poorly it will kick your ass.

There's my contribution to the source code section for now.
Last edited on
It's the dll-s.

Try linking statically to SFML. If you're using Code::Blocks, you'll have to either get the official MinGW or build SFML from source with Code::Blocks's (TDM) MinGW. If you choose the official MinGW way (easier IMO), you'll have to also statically link to libstdc++ and libgcc (IIRC).

There's my contribution to the source code section for now.

Where are they? I want to play!
I just checked and they are both still awaiting approval.

@m4ster0shi. Thanks for the tips. I've been using Code::Blocks for some time now (v 4.4.1 w MinGW). I thought I knew how to manipulate the build options and set library paths correctly but I can't get it.

I'm getting link errors which were "undefined reference to..." and are now "multiple definitions of..."

Also, there are no static files (in the SFML/1.6/lib folder) named libstdc++ and libgcc, although there are .dll versions by these names.

I'll update the articles with the static versions when I get them built.
Meanwhile, I neglected to mention which version of SFML I'm using. It is 1.6

EDIT: I got it! I had everything right but I needed to perform a build from scratch (not just change the source file then build). I still need the 2 dlls above though (libstdc++ and libgcc). I'll look deeper into m4ster0shis hint re. statically linking to these as well.
EDIT2: I found several files in MinGW\lib\gcc\mingw32\4.5.2 named libgcc and libstdc++ (several extensions each).
Last edited on
I wonder how many copies of the same libraries you have distributed across the file system.
¿isn't there a standard path to look for dlls?
Also, there are no static files (in the SFML/1.6/lib folder) named
libstdc++ and libgcc, although there are .dll versions by these names.

Ah, yes, I should have clarified. These files are MinGW (not SFML) specific.

I found several files in MinGW\lib\gcc\mingw32\4.5.2 named libgcc and libstdc++ (several extensions each).

The ones you're looking for are probably these ending with .a or .lib. It
doesn't matter if you can or can't find them though. Adding these lines...

-static-libgcc
-static-libstdc++

in...

Project -> Build options -> Linker settings -> Other linker options

for all builds (your project's name (instead of Debug or Release or some other build
you may have) should be selected in the tree widget to the left) should do the trick.

Meanwhile, I neglected to mention which version of SFML I'm using. It is 1.6

Same here.

I wonder how many copies of the same libraries you have distributed across the file system.

Haha, I do that too. Being able to tell what the dependencies of an
executable are by just looking at the bin directory is useful sometimes.
Last edited on

-static-libgcc
-static-libstdc++

Those were the magic words! Thank you!

And yes, it is the .a versions which work:
libgcc.a
libstdc++.a


On my own I tried the following. Already listed as Other linker options are:

-lsfml-graphics-s
-lsfml-window-s
-lsfml-system-s

I wanted to add libgcc and libstdc++ to this but I saw the names of the sfml libs preceded by -l, so I tried:

-lsfml-graphics-s
-lsfml-window-s
-lsfml-system-s
-llibgcc
-llibstdc++

The result was a bit alarming. It builds fine but leaves the folder bin\Release empty. I stopped experimenting when that happened.

I wonder how many copies of the same libraries you have distributed across the file system.

Umm... 50? I think it's mainly limited to copies of the same dlls in every project folder.

I have a (full) statically linked version ready for checkers. Now I'll try it for the
card game. Thank you m4ster0shi for guiding me through those couple of steps where I hadn't tread before.

EDIT: Got it on the first try for the rummy program.
Last edited on
Why are you statically linking everything?

[edit: p.s. I'm pretty sure if you statically link the gcc and g++ libs, your program has to be GPL]
Last edited on
Maybe I'm missing something.. but I believe the source code section would be for source code. Not binaries produced by compiling and linking source code or libraries that source code needs to be linked against.
Maybe I'm missing something.. but I believe the source code section would be for source code. Not binaries produced by compiling and linking source code or libraries that source code needs to be linked against.

Bingo.
I am preparing a zip file for attachment which contains all source code and images used with an exe thrown in so that the reader could simply unzip and run the program if he just wanted to test it out.

The linkage issue arose when I tried uploading a zip with all 5 dlls needed by the exe in it. At 9Mb it wouldn't upload.

EDIT: Sorry about the threadjacking there Catfish, I should be done now.
Last edited on
Maybe I'm missing something.. but I believe the source code section would be for source code. Not binaries produced by compiling and linking source code or libraries that source code needs to be linked against.


What happens when new versions of the dependencies come out that break the code that's found on the source code section? I think it'd be a good idea to include dependencies instead of having the users hunt all over the internet trying to find version X.Y.Z (that they might not be able to). Any non-trivial project could potentially have dozens of dependencies, any one of which becomes incompatible, invalidates the entire project in respect to the 'new programmers' that will be using it. (and don't even get me started about the dependencies of the dependencies! It's a vicious cycle in a lot of open source projects...)

Example:

To use BoneCP (a java-based database pooling API), IIRC one needs "Apache Commons Logging" -- no version specified, but will break with the wrong version, then the commons logging needs the "Commons-Core" in addition to a specific logging back-end implementation.
Last edited on
Pages: 12