Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Development & Programming > Programming Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Programming Talk
This forum is for all programming questions.
The questions do not have to be directly related to Ubuntu and any programming language is allowed.

 
Thread Tools Display Modes
Old July 16th, 2005   #1
csalinas
First Cup of Ubuntu
 
Join Date: Jul 2005
Beans: 4
Path to the C++ libraries

I can compile helloworld.cpp with #include <iostream> and everything works fine.

However, when I try to add #include "random.h" and a function that uses Randomize()
I get a compile-time error, no referenece to Randomize.

I am using namespace std;

Where does Ubuntu/Synaptic put the C++ library?
Do I have to set the path to that directory?
Are libraries from boost only looked at at compile-time? I tried to grep the .h files for "Randomize()"

Thanks in advance to anyone who can help me with this.

Chad
csalinas is offline   Reply With Quote
Old July 16th, 2005   #2
LordHunter317
Tall Cafè Ubuntu
 
Join Date: Nov 2004
Beans: 2,614
Re: Path to the C++ libraries

I'm not 100% certain, but I'm pretty sure Randomize() isn't part of the C standard, C++ standard, or POSIX, so it wouldn't be provided by Ubuntu.

If it's your own function, you'll have to provide the header yourself.

And a file named "random.h" would certianly not be part of the C++ standard, and isn't in the C one, so...
LordHunter317 is offline   Reply With Quote
Old July 17th, 2005   #3
vintem
First Cup of Ubuntu
 
Join Date: Jun 2005
Beans: 11
Re: Path to the C++ libraries

on my computer (with hoary) the C++ header file are in:
/usr/include/c++/3.3

there you have cstdlib (the new name of stdlib.h). If you #include this, you can use rand(), which returns an int. This program prints 5 random integers:

#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
for (int i = 0; i < 5; ++i){
cout << rand() << endl;
}
return 0;
}
vintem is offline   Reply With Quote
Old July 17th, 2005   #4
csalinas
First Cup of Ubuntu
 
Join Date: Jul 2005
Beans: 4
Re: Path to the C++ libraries

Thanks so much, I now see that I have been using a lot of non-standard libraries in .Net C++ projects so porting them will invovle re-writing some of the .h or finding an appropriate standard .h and then changing my code.

Chad Salinas
csalinas is offline   Reply With Quote
Old July 26th, 2005   #5
csalinas
First Cup of Ubuntu
 
Join Date: Jul 2005
Beans: 4
Re: Path to the C++ libraries

Chad Salinas at stanford : g++
Chad Salinas at stanford : emacs
Chad Salinas at stanford : /usr/include
Chad Salinas at stanford : GNOME
Chad Salinas at stanford : Dual boot Windows XP / Ubuntu
Chad Salinas at stanford : AHA vs AHCI
Chad Salinas at stanford : USB Wireless
Chad Salinas at stanford : Synaptic Package Manager
Chad Salinas at stanford : /usr/bin
Chad Salinas at stanford : gcb
Chad Salinas at stanford : .xsession file
Chad Salinas at stanford : .emacs file
Chad Salinas at stanford : .bash-profile
Chad Salinas at stanford : Dinkum C++ library conforms to Standard C++ library
Chad Salinas at stanford : C++ callbacks
Chad Salinas at stanford : cluster algorithmChad Salinas at stanford : g++
Chad Salinas at stanford : function pointer tutorials
Chad Salinas at stanford : SGI Standard Template Library
Chad Salinas at stanford : Arithmetic on void pointer
Chad Salinas at stanford : heap advantages
Chad Salinas at stanford : heap disadvantages
Chad Salinas at stanford : activation protocol
Chad Salinas at stanford : RV register
Chad Salinas at stanford : Call and Return
csalinas is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:07 PM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry