Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


New to Linux based programming


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 wicked357   Members   -  Reputation: 1267

Like
0Likes
Like

Posted 04 May 2011 - 03:03 PM

I just recently installed Ubuntu on a virtual machine and I got Eclipse Helios C++ IDE running with the most current version of G++. Everything checked out good and working with a simple console program. I am looking at doing something like this but not too sure where to start as I am new to the whole makefile thing. I want to be able to make a makefile based command line application that will implement two passive event driven state machines with a main loop to drive them. I am looking to be pointed in the right direction or some tips/hints to get me started, please talk to me like I am new to everything since using the Linux environment for programming and makefiles are completely new to me. Any help is much appreciated and thank you in advance.

Sponsor:

#2 Riztro   Members   -  Reputation: 240

Like
-2Likes
Like

Posted 04 May 2011 - 04:42 PM

Well I was on ubuntu for awhile and am now on debian and what I have learned is that it is almost easier to skip the makefile and just make a script. Now I would recommend trying to use the command line for almost everything for awhile to truely get used to it and maybe even use vim or vi as a text editor. Then once you know how to use the command line, you can start developing applications on it. What you will be using is g++ to compile. Ex.
g++ -o ProgramName (source files) main.cpp engine.cpp camera.cpp (then linker flags) -lGL -lsfml-window -lsfml-graphics
Then once you know how to compile your own projects on the command line, you can start making scripts or makefiles (I personally like scripts better). Now here is a small tutorial on how I make a script.
1. Open up terminal
2. go to project directory // My directories usually dont have IDE project files in them, just souce and media.
3. type "vi (or any other text editor) m.sh" //This is where you start editing you script
4. type your commands you wish to execute. Ex. g++ -o MyProgram main.cpp // This is where you fill you script with commands.
5. Save
6. type "chmod +x m.sh" //You change the file to be executable
7. type "./m.sh" //This will compile your project

Now if you would like to use a makefile I think its pretty close. Just look up some tutorials about makefiles if you would like to learn about those.

#3 Prefect   Members   -  Reputation: 373

Like
0Likes
Like

Posted 04 May 2011 - 11:54 PM

The documentation of GNU make is actually fairly thorough, so you can read through that, and/or just look for sample Makefiles of some project.

However, very few serious projects use Makefiles directly. It is more common to use higher-level tools like the autotools (autoconf/automake) or CMake. Especially CMake is fairly simple to set up, and you basically only specify a list of your source files. CMake will take care of setting up the proper Makefiles, including header dependencies and all that.
Widelands - laid back, free software strategy

#4 KulSeran   Members   -  Reputation: 2581

Like
2Likes
Like

Posted 05 May 2011 - 12:07 AM

I'd suggest something like CMake instead. It makes the whole process a lot easier, and cross platform if you care for that.
In the end, it outputs a makefile or project file of your choice, that you can build in the regular way on linux, so you end up with something like:

cmake ./ && make && make install

But it also spits out Visual Studio project files if you take it over to windows.

#5 Katie   Members   -  Reputation: 1371

Like
0Likes
Like

Posted 05 May 2011 - 02:50 AM

"I want to be able to make a makefile based command line application that will implement two passive event driven state machines with a main loop to drive them."

I think you may have slightly misunderstood what make is for. Make isn't a tool to use in your applications -- it's a build tool. The makefile describes how to compile files into other files, how to join multiple files into files and how which files depend on other files. Make then "solves" that graph building the elements as it goes.

If that's not the case, then could you elaborate a little more on what you're trying to build.

#6 wicked357   Members   -  Reputation: 1267

Like
0Likes
Like

Posted 08 May 2011 - 06:25 PM

Ok, I will elaborate step by step what I am to do in this challenge. Even though it is past my time, I would still like to understand and figure it out.

1. Create a simple makefile based command line application.
**It implements two passive event driven state machines with a main loop to drive them.
**Passive meaning neither block execution of the other for a prolonged period of time.
**Main loop should periodically call into each state machine to give each a chance to run with each state machine returning to the main loop as quickly as possible.

I left out the programming part as I already know how to do that, I just don't understand this makefile part of it. Anyone else able to elaborate on the exact meaning of this cause above is word for word.

#7 Katie   Members   -  Reputation: 1371

Like
0Likes
Like

Posted 10 May 2011 - 07:45 AM

Makes no sense to me I'm afraid.

#8 A Brain in a Vat   Members   -  Reputation: 313

Like
0Likes
Like

Posted 10 May 2011 - 07:53 AM

Why do you keep on talking about the "event driven state machines with a main loop to drive them"? These are details of the program. These are not details of the build system.

make is a build system. It will build your project for you. It doesn't care if it's an event-driven state machine or the embedded code for one of those automated kitty litter boxes.

Anyway, there's ample information on the internet about how to use make. Use google.

#9 Bregma   Crossbones+   -  Reputation: 5353

Like
0Likes
Like

Posted 10 May 2011 - 08:14 AM

It sounds like you want a makefile containing something like this.

two_machines_one_cup: machine1.o machine2.o main.o

  $(CC) -o $@ $^

That says "the executable program two_machines_one_cup out of the compiled object files machine1.o, machine2.o, and main.o ... use your implicit rules to generate those .o files from whatever you find in the current directory, like maybe main.cpp, machine1.for, and machine2.mm." The rest is dark and unspeakable magic that can be revealed to uninitiated by the evil incantation "info make".
Stephen M. Webb
Professional Free Software Developer




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS