Have you tried GCC? i.e.
g++ nameofprogram.cp -o anyname
Hi!
Using KNOPPIX 5.0.1CD, the gcc compiler for C has no trouble finding stdio.h. The C++ compiler cannot find iostream.
1. Do you have any suggestions for a work-around?
2. I'm going to be remastering this version of KNOPPIX to have some tools that aren't in the standard version, so I could change path variables, etc. What needs to be changed?
Thanks,
Fred
Have you tried GCC? i.e.
g++ nameofprogram.cp -o anyname
Thanks, WaKa!
What I did was the simple "hello, world!" program in C and C++, using exactly the format you suggested.
For C, it worked absolutely as expected, so I was surprised when it couldn't find iostream for the C++ version of the program (using cout << "Hello, world!" << endl; ), and I got the error message that ostream was not defined in this function! I gave it this:
#include <iostream>
for C++, just like I gave it:
#include <stdio.h>
for the C case. I tried the alias for gcc (g++), as well. If I specifically gave the absolute path to iostream it worked.
Since this is a Live CD, however, I'd have to re-master to add a PATH or an alias.
So suggestions are still welcome!
--Fred
use this:
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
Thanks for your reply, WaKa.
The problem is that gcc can't find the #include file iostream, not that it's using the wrong namespace.
Whe I use the -v (verbose) output, it tells met that it is, in fact, looking in a non-existent directory. - many directories deeper than the real one.
Does the program you gave actually work on your copy of KNOPPIX 5.0.1CD? If so, then I'll have to try another download.
Thanks,
Fred
FYI, here's the response to the gcc invocation:
knoppix@1[~]$ gcc -v test.cpp -o test
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk-default --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
/UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.0.4/cc1plus -quiet -v -iprefix /UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.0.4/ -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -mtune=i686 -auxbase test -version -o /tmp/cclr3aiv.s
ignoring duplicate directory "/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4"
ignoring duplicate directory "/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/i486-linux-gnu"
ignoring duplicate directory "/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/backward"
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring duplicate directory "/usr/lib/gcc/i486-linux-gnu/4.0.4/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4
/UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/i486-linux-gnu
/UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/backward
/UNIONFS/usr/bin/../lib/gcc/i486-linux-gnu/4.0.4/include
/usr/local/include
/usr/include
End of search list.
GNU C++ version 4.0.4 20060507 (prerelease) (Debian 4.0.3-3) (i486-linux-gnu)
compiled by GNU C version 4.0.4 20060507 (prerelease) (Debian 4.0.3-3).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129331
test.cpp: In function 'int main()':
test.cpp:8: error: 'cout' was not declared in this scope
test.cpp:8: error: 'endl' was not declared in this scope
As I read this, gcc is looking in a bunch of wrong directories for the C++ include files.
--Fred
Post your source code. I think it is that you are not using the STD namespace.
You should do this in your file:
#include <iostream>
using namespace std;
int main (void)
{
cout << "Hello World!" << endl;
return 0;
}
See if that works. If that doesn't work, post your source.
gcc is the compiler for CCode:knoppix@1[~]$ gcc -v test.cpp -o test
g++ is the compiler for C++
test(name of program) is not a unique name because it conflicts with bash.
use this
g++ -v test.cpp -o test_1 (or what ever you like)
A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G
$13.99
HyperX FURY DDR3 8GB 16GB 32GB 1600 MHz PC3-12800 Desktop RAM Memory DIMM 240pin
$12.90
Samsung 128GB (4x 32GB) M86B4G70DM0-CMA3 PC3-14900L 4Rx4 DDR3 ECC Reg Server Mem
$39.99
Team T-FORCE VULCAN Z 16GB (2 x 8GB) 288-Pin PC RAM DDR4 3200 (PC4 25600) XMP
$35.99
HyperX FURY RAM DDR4 16GB 8GB 32GB 4GB 3200 2666 2400 2133 Desktop Memory DIMM
$9.64
A-Tech 8GB PC3-12800 Desktop DDR3 1600 MHz Non ECC 240-Pin DIMM Memory RAM 1x 8G
$13.99
Kingston HyperX FURY DDR3 8GB 16GB 32G 1600 1866 1333 Desktop Memory RAM DIMM
$13.25
8GB PC3L-12800S 1600MHz SODIMM DDR3 RAM | Grade A
$12.00
A-Tech 256GB 4x 64GB 4Rx4 PC4-19200 ECC Load Reduced LRDIMM Server Memory RAM
$287.96
G.Skill RipJaws V 16GB (2x8GB) PC4-28800 (DDR4-3600) Memory F4-3600C16D-16GVKC
$45.00