Author Topic: G++  (Read 14082 times)

0 Members and 5 Guests are viewing this topic.

Offline AntiVirus

  • Legendary
  • x86
  • Hero Member
  • *****
  • Posts: 2521
  • Best
    • View Profile
Re: G++
« Reply #15 on: August 31, 2006, 02:27:59 pm »
I am doing it at home. :P

I am just doing what my professor told me to do.  No need to argue, he probably has it set up like that because of the way the files are accepted or something to that nature.
The once grove of splendor,
Aforetime crowned by lilac and lily,
Lay now forevermore slender;
And all winds that liven
Silhouette a lone existence;
A leafless oak grasping at eternity.


"They say that I must learn to kill before I can feel safe, but I rather kill myself then turn into their slave."
- The Rasmus

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: G++
« Reply #16 on: August 31, 2006, 04:26:55 pm »
I am doing it at home. :P

I am just doing what my professor told me to do.  No need to argue, he probably has it set up like that because of the way the files are accepted or something to that nature.

No, he's likely doing it because you're new to it and he doesn't want to confuse you, so the "do it exactly like this"-style of thing is more useful.  Once you do it for awhile, you should start to figure out what the different flags do, why you're doing it that way, etc.  But all in time..

Offline AntiVirus

  • Legendary
  • x86
  • Hero Member
  • *****
  • Posts: 2521
  • Best
    • View Profile
Re: G++
« Reply #17 on: August 31, 2006, 05:31:03 pm »
Yes.. All in time.
The once grove of splendor,
Aforetime crowned by lilac and lily,
Lay now forevermore slender;
And all winds that liven
Silhouette a lone existence;
A leafless oak grasping at eternity.


"They say that I must learn to kill before I can feel safe, but I rather kill myself then turn into their slave."
- The Rasmus

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: G++
« Reply #18 on: September 01, 2006, 02:23:44 pm »
Hrmmm.. Now I feel dumb, but how do I open a .tar file?  And does G++ have an IDE version?  Does any of that make sense?

I feel so stupid. :(

WinZip will open a .tar file as well as .tar.gz and I believe .tar.bz2 files.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline AntiVirus

  • Legendary
  • x86
  • Hero Member
  • *****
  • Posts: 2521
  • Best
    • View Profile
Re: G++
« Reply #19 on: September 01, 2006, 02:38:50 pm »
Alright, cool.  That'll help me in the future. ^^

Danke, Myndfyre.
The once grove of splendor,
Aforetime crowned by lilac and lily,
Lay now forevermore slender;
And all winds that liven
Silhouette a lone existence;
A leafless oak grasping at eternity.


"They say that I must learn to kill before I can feel safe, but I rather kill myself then turn into their slave."
- The Rasmus

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: G++
« Reply #20 on: September 01, 2006, 02:54:04 pm »
Just use WinRar. :-\

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: G++
« Reply #21 on: September 01, 2006, 06:26:19 pm »
Hrmmm.. Now I feel dumb, but how do I open a .tar file?  And does G++ have an IDE version?  Does any of that make sense?

I feel so stupid. :(

WinZip will open a .tar file as well as .tar.gz and I believe .tar.bz2 files.

Last time I checked, WinZip didn't auto-associate with .tar files, so I just assumed it didn't recognize them.  Maybe that was a mistake. 

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: G++
« Reply #22 on: September 01, 2006, 06:57:29 pm »
I've never opened a bzip2 or gzip file with winzip, so I wouldn't have guessed that either.  I like WinRar quite a bit more anyway.

Offline Rule

  • x86
  • Hero Member
  • *****
  • Posts: 1588
    • View Profile
Re: G++
« Reply #23 on: September 02, 2006, 12:38:09 am »
re: long "g++ command"...

Make a C/C++ program to do it for you :)

Something like...

clink.c
Code: [Select]
#include <stdlib.h>
#include <stdio.h>

void usage();

int main(int argc, char *argv[])
{
  char *flags = "-W -Wall -s -pedantic-errors";
  char compilecommand[150]="\0";

  if (argc != 3)  usage();
 
  else
  {
    snprintf(compilecommand, 149, "g++ %s %s -o %s", flags, argv[1], argv[2]);
    system(compilecommand);
  }

  return 0;
}

void usage()
{
  fprintf(stderr, "Usage: ./clink [source file] [desired name of executable]\n");
  fprintf(stderr, "Example: ./clink testprog.c testworked\n");
  fprintf(stderr, "Warning: If the combined lengths of the source file and executable are too long,
           compilation and linking will not be successful\n");


Where I am (today), I don't have easy access to a C compiler or the time to access one.  So, that code might have bugs (I wrote it in 90 seconds, and I didn't test it)!  If so, treat it as a debugging exercise, but I hope it's bug free and makes your life easier. :)

Of course, writing a makefile would ordinarily make more sense, but this is a good way to practice C.

Edit: To compile clink.c, try something like
Code: [Select]
gcc -ansi -pedantic -Wall clink.c -o clink

To give yourself permission to execute clink,
Code: [Select]
chmod u+x clink

Also, you're lucky to be learning C++ and not Java as a first language!
« Last Edit: September 02, 2006, 12:54:23 am by Rule »

Offline Newby

  • Moderator
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: G++
« Reply #24 on: September 02, 2006, 01:19:48 am »
Just write a really simple shell script program to do it for you. I mean, that's nice for practicing his C and all, but he'll have plenty of time to learn C. :)

Quote
newby@impaler:~/programming$ cat test.c
#include <stdio.h>

int main()
{
        printf("Hello, world!\n");
        return 0;
}
newby@impaler:~/programming$ ./clink.sh test.c outputfile
newby@impaler:~/programming$ ./outputfile
Hello, world!

Code: [Select]
newby@impaler:~/programming$ cat clink.sh
#!/bin/sh

FLAGS='-W -Wall -s -pedantic-errors'

if [ $# -ne 2 ]; then
        echo 1>&2 "Usage: $0 [source file] [desired executable of name]"
        echo 1>&2 "Example: ./$0 testprog.c testworked"
        echo 1>&2 "Warning: If the combined lengths of the source file and executable are too long, compilation and linking will not be successful"
else
        gcc $FLAGS $1 -o $2
fi
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline Explicit

  • Hero Member
  • *****
  • Posts: 717
  • Hail Bender!
    • View Profile
Re: G++
« Reply #25 on: September 02, 2006, 01:29:23 am »
I think you guys may be over-complicating things, at least for now.
Quote
Like all things in life, pumping is just a primitive, degenerate form of bending.

Quote
Hey, I don't tell you how to tell me what to do, so don't tell me how to do what you tell me to do! ... Bender knows when to use finesse.

[13:41:45]<@Fapiko> Why is TehUser asking for wang pictures?
[13:42:03]<@TehUser> I wasn't asking for wang pictures, I was looking at them.
[13:47:40]<@TehUser> Mine's fairly short.

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: G++
« Reply #26 on: September 02, 2006, 09:15:35 am »
Not really. It's a good practice in programming to automate the building process. Although, all of you should keep in mind that he's on Windows (or at least I thought he was!)

Offline AntiVirus

  • Legendary
  • x86
  • Hero Member
  • *****
  • Posts: 2521
  • Best
    • View Profile
Re: G++
« Reply #27 on: September 02, 2006, 03:58:36 pm »
If you are talking about me, then yes, I am on Windows. :P

I don't have *nix on my laptop yet, but I do have to telnet over to a UNIX server to submit my homework and compile my program.
« Last Edit: September 02, 2006, 04:02:01 pm by AntiVirus »
The once grove of splendor,
Aforetime crowned by lilac and lily,
Lay now forevermore slender;
And all winds that liven
Silhouette a lone existence;
A leafless oak grasping at eternity.


"They say that I must learn to kill before I can feel safe, but I rather kill myself then turn into their slave."
- The Rasmus

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: G++
« Reply #28 on: September 02, 2006, 04:33:51 pm »
... telnet?  surely you mean ssh? :(

Offline Rule

  • x86
  • Hero Member
  • *****
  • Posts: 1588
    • View Profile
Re: G++
« Reply #29 on: September 02, 2006, 04:36:47 pm »
It could be telnet :P.  Makes me sentimental for a time that has long passed. :'(