Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 19 of 19
It seems that your problem is already known: g++ kompilieren schlägt fehl and gcc #include file path OK for C, doesn't work for C++ . Both threads basically say that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120

    It seems that your problem is already known: g++ kompilieren schlägt fehl and gcc #include file path OK for C, doesn't work for C++. Both threads basically say that the include path is somehow configured incorrectly for g++ in Knoppix. In your case you have a similar problem: g++ searches for header files under /UNIONFS/ which, apparently, does not contain anything (at least).

    Could you please post the output of the following:
    Code:
      $ ls /UNIONFS
    If my hypothesis proves right (and you don't have /UNIONFS/ ), the solution would be to instruct g++ to look for include headers under the right path. According to man gcc, the -I option should work.

    Try the following:
    Code:
      $ g++ -I/usr/include/ HelloWorld.cc -o HelloWorld
    This will prepend the correct directory to the list of directories g++ searches for header files.

    What has just occurred to my mind is that g++ may have a wrong idea about where the system root is. To check this, type:
    Code:
      $ g++ --print-sysroot
    If this prints something like /UNIONFS/, we are on the right track.

    In this case an idea which is much better than using -I should be changing the sysroot value g++ knows. According to my reading of the man page, one of the following should work:

    Code:
      $ g++ --isysroot=/ HelloWorld.cc -o HelloWorld
                 or
      $ g++ --sysroot=/ HelloWorld.cc -o HelloWorld
    (Note sysroot vs. isysroot).

    I'll state it once more that, out of the two possible solutions, I'd prefer the second one, should it work

  2. #12
    Just Joined!
    Join Date
    Sep 2010
    Posts
    6
    The /UNIONFS directory isn't empty:

    knoppix@Microknoppix:~$ ls /UNIONFS
    bin dev home media opt root selinux sys tmp var
    boot etc lib mnt proc sbin srv tftpboot usr vmlinuz

    Furthermore, when I tried g++ --print-sysroot, the screen read

    g++: not configured with sysroot headers suffix

    Any thoughts? Also, while I'm here, I should probably know how to add code to a post; how do I achieve this?

    Thanks

  3. #13
    Linux Newbie
    Join Date
    May 2009
    Location
    Kitchener, Ontario, Canada
    Posts
    206
    Hey i actually had the exact same problem. since you want to program in C++ change the file extention to .cpp, this is a c++ file. thats why your getting errors with with the preproccessor iostream. if you want to look at my thread just do a advannced search on my user name and it will come up.

    so change the file extention to .cpp end enter the code below
    Code:
    # g++ HelloWorld.cpp -o HelloWorld
    for code use code tags, its the # sign

    PM if you have any other questions. I just started learning C++ so we noobs can help each other out.
    Last edited by donaldfarkas; 09-07-2010 at 04:41 PM.

  4. #14
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120
    Quote Originally Posted by Rudipoo View Post
    Any thoughts?
    You really should try donaldfarkas's suggestion. I, too, remember having problems with some GNU compilers when the extensions of my files deviated from the common ones somehow.

    Quote Originally Posted by Rudipoo View Post
    Also, while I'm here, I should probably know how to add code to a post; how do I achieve this?
    Surround your code with CODE tags:
    Code:
      [ CODE]
        <your code>
      [ /CODE]
    Please note that I inserted the spaces after '[' so that the rendering engine of the Forums would not interpret the construction as nested blocks of code. You don't need to keep that space.

    Also, take a look at the second row of the toolbar just above the text box where you write the post and find the third button from the right, marked with a "#" sign.

  5. #15
    Linux Newbie
    Join Date
    May 2009
    Location
    Kitchener, Ontario, Canada
    Posts
    206
    Quote Originally Posted by unlimitedscolobb View Post
    You really should try donaldfarkas's suggestion. I, too, remember having problems with some GNU compilers when the extensions of my files deviated from the common ones somehow.

    Well as far as i know .cc is just for C programming thats why the #include <iostream> wont work for him all he as to do is change the extention from .cc to cpp and it compile it and it should work i ran into the exact same problem 2 weeks ago.

  6. #16
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120
    Quote Originally Posted by donaldfarkas View Post
    Well as far as i know .cc is just for C programming
    Not sure what you mean, but I remember it being mentioned in a number of sources that ".cc" is one of the extensions for C++ source files (the sources count both the Internet and some physical books I've read). I believe that the special treatment is pretty g++-specific.

  7. #17
    Linux Newbie
    Join Date
    May 2009
    Location
    Kitchener, Ontario, Canada
    Posts
    206
    Quote Originally Posted by unlimitedscolobb View Post
    Not sure what you mean, but I remember it being mentioned in a number of sources that ".cc" is one of the extensions for C++ source files (the sources count both the Internet and some physical books I've read). I believe that the special treatment is pretty g++-specific.
    Oh Okay. Thanks for the info.

  8. #18
    Just Joined!
    Join Date
    Sep 2010
    Posts
    1
    Quote Originally Posted by ILikeWaffles View Post
    I seem to be having the same issues...see my thread below yours.

    Maybe we need the dvd version of knoppix.
    Seems like you don't have g++ installed. I don't know much about Knoppix, I have tried it briefly some time, but I guess you have some kind of package manager of some kind where you can search for software and install it with a few clicks.

    Best regards

  9. #19
    Just Joined!
    Join Date
    Jan 2011
    Posts
    1
    Quote Originally Posted by Rudipoo View Post
    I'm afraid your hint didn't work unlimitedscolobb; after saying

    Reading package lists... Done
    Building dependancy tree
    Reading state information... Done

    the terminal reads

    E: couldn't find package build-essential

    So, any other suggestions? Is it certain that the cd version has a c++ compiler?

    Thanks
    Please note that I am not trying out the commands I suggest within a Knoppix LiveCD environment, but I cannot see any reason for a C++ compiler not to be accessible from this environment. I may be wrong, however

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •