Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-03-2009, 01:42 AM   #1
Registered: Dec 2003
Location: Milano (ITALY)
Distribution: Kubuntu 12.04
Posts: 237

Rep: Reputation: 30
NetBeans C++ setup on Linux - problems with debugging functionalities

I just installed Netbeans 6.5 (downloaded from Kubuntu repository)and set-up its plugins for C++.

I tested it with this simple code

//: C02:Scopy.cpp
// Copy one file to another, a line at a time
#include <string>
#include <fstream>
using namespace std;
int main() {
ifstream in("Scopy.cpp"); // Open for reading
ofstream out("Scopy2.cpp"); // Open for writing
string s;
while(getline(in, s)) // Discards newline char
out << s << "\n"; // ... must add it back
} ///:~

I compiled it (Run/Build), navigated to the directory where I found the executable, put a sample file "Scopy.cpp" in it, run the program with ./<name>, and it worked fine, it created Scopy2.cpp in the same directory and I was happy.

Then i tested the NetBeans Debug functions ("Step into" and "Step over", keys F7 and F8) and I stopped being happy.

I just can't get it to work, it does not seem to open the file for reading: I am sure of it because it does not enter the While block, and so I added the line

bool h=in.Is_Open();

and h remains "false".

Any idea? I thought that there must be some setup to indicate the path in which to look for files, and so I tried also to substitute

ifstream in("Scopy.cpp");


ifstream in("/home/.../Scopy.cpp");

but nothing changed.

Old 12-03-2009, 04:03 AM   #2
LQ Newbie
Registered: Jan 2008
Posts: 25

Rep: Reputation: 16

Try open the file in a different way, it might help to solve the problem.

Try the c stdio.h header and use, freopen(name, mode, filestream) to get and put files.

#include <stdio.h> // need this
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char ** argv){

freopen("filename.txt", "r", stdin); // to get stdin from the files
freopen("filename.txt", "w", stdout);


cout << "Hello world" << endl; // puts into your file.

string str;
while(cin >> str){ // will get from your file.
vector<string> lines;lines.push_back(str); // and plant it in a vector
return 0;
I hope it solves the problem.
Old 12-03-2009, 04:52 AM   #3
Registered: Dec 2003
Location: Milano (ITALY)
Distribution: Kubuntu 12.04
Posts: 237

Original Poster
Rep: Reputation: 30
Well, thanks bu it is not exactly what I was looking for...

My problem is not related to code: it just works, once it is compiled.

My problem is that I need a working debugging environment, and at the moment when I go through the code line by line with the debugger I don't obtain the same results as when I run the compiled code...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems debugging usermode linux kernel with gdb StevenR Linux - Kernel 2 02-02-2009 03:14 AM
graphical Linux router with firewall functionalities yiux Linux - Networking 0 02-20-2007 08:45 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
network debugging and setup for newbie littleg Linux - Networking 2 12-11-2004 11:09 AM
Linux and XP NOS functionalities farhan Linux - Networking 5 12-06-2004 04:01 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:04 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration