Hi all, how do i compile a c++ program in linux??? i am using ubuntu and i have the g++ compiler installed...
Please help???
Hi all, how do i compile a c++ program in linux??? i am using ubuntu and i have the g++ compiler installed...
Please help???
i tried that, it didn't work..... what i am working on a program to help me clean and sort out and merge my word lists for pentesting...
now i dont know if it will work at all as i have never tried to program anything in linux before...
that is what i have done so far, as im sure you know all it dose is take the words from a file name pass from argv and display them... but as i am new to programing in linux, i am vary lost...Code:#include <cstdlib> #include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]) { string temp[100]; ifstream wordlist_in; wordlist_in.open (argv[1]); if (wordlist_in.is_open()) { for (int i=0;;i++) { getline (wordlist_in, temp[i]); cout << temp[i] << endl; if (wordlist_in.eof()) { break; } } } return EXIT_SUCCESS; }
How does it not work?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Post your console log as well, showing how you compiled it as well.
Perhaps you're confused as to how to run the result?
In which case, try typing this at your command prompt after compiling
./a.out myfile.txt
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Well i know the code i have so far works fine, because what i have done so far i have done in windows... where i have compiled it and run it...
where i am getting confused is how do i do it in linux... i run the command g++ WordList.cpp it dose something for a while, and then nothing changes... i know in linux there isn't ".exe" file... so when i run the g++ command where is my program compiled and placed? How do i get at it????? :S
MacGyver's example will produce a file named a.out that you can run from the command line. If you want a more appropriate name for the executable program, you can write:where i am getting confused is how do i do it in linux... i run the command g++ WordList.cpp it dose something for a while, and then nothing changes... i know in linux there isn't ".exe" file... so when i run the g++ command where is my program compiled and placed? How do i get at it????? :S
Then run it, e.g.,Code:g++ -o executable source.cpp
Code:./executable
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
ah ok, thanks heaps... i only just made the switch from windows to linux.... and there are so many things i have to start learning again...
Aye, you may wish to read or at least bookmark the GCC documentation for future reference.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)