473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

compilation problem (port cpp from windows)

I have a small program to read data from some data files , in it I use
string types to build the data file name but when I try to compile it I
get: (see code below error)
root@rob-laptop:/home/rob/pankaj# gcc ptcllocate.cpp
/tmp/ccg9j6Mi.o: In function `main':ptcllocate.cpp:(.text+0x99):
undefined reference to `std::allocator<char>::allocator()'
:ptcllocate.cpp:(.text+0xb9): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(char const*, std::allocator<charconst&)'
:ptcllocate.cpp:(.text+0xc7): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0xd5): undefined reference to
`std::allocator<char>::allocator()'
:ptcllocate.cpp:(.text+0xf5): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(char const*, std::allocator<charconst&)'
:ptcllocate.cpp:(.text+0x111): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x133): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x141): undefined reference to
`std::allocator<char>::allocator()'
:ptcllocate.cpp:(.text+0x161): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(char const*, std::allocator<charconst&)'
:ptcllocate.cpp:(.text+0x17d): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x196): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x1d6): undefined reference to
`std::allocator<char>::~allocator()'


any Idea what I am missing?
code:
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <math.h>
#include <iomanip>
#include <string>

int main(int argc,char *argv[])
{
using namespace std;
int i,j;
long double
x[19500],y[19500],z[19500],c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,m1,m2,m3,m 4,m5,m6,m7,m8,m9,m10,m11,m12,a=0,b=0,c=0,f=0,k;
long double l, m, n, o ;

string beginning = "count";
string endding = ".txt";
string outf = "data";
string cf1(beginning + argv[0] + endding);
string cf2(beginning + argv[1] + endding);
string cf3(beginning + argv[2] + endding);
string cf4(beginning + argv[3] + endding);
string cf5(beginning + argv[4] + endding);
string cf6(beginning + argv[5] + endding);
string cf7(beginning + argv[6] + endding);
string cf8(beginning + argv[7] + endding);
string cf9(beginning + argv[8] + endding);
string cf10(beginning + argv[9] + endding);
string cf11(beginning + argv[10] + endding);
string cf12(beginning + argv[11] + endding);
string of1(outf + argv[1] + "_" + argv[11] + endding);
ifstream in1(cf1.c_str());
ifstream in2(cf2.c_str());
ifstream in3(cf3.c_str());
ifstream in4(cf4.c_str());
ifstream in5(cf5.c_str());
ifstream in6(cf6.c_str());
ifstream in7(cf7.c_str());
ifstream in8(cf8.c_str());
ifstream in9(cf9.c_str());
ifstream in10(cf10.c_str());
ifstream in11(cf11.c_str());
ifstream in12(cf12.c_str());
ifstream in13;
ifstream in14;
ifstream in15;
ifstream in16;
ifstream in17;
ifstream in18;
ifstream in19;
ifstream in20;
ifstream in21;
ifstream in22;
ifstream in23;
ifstream in24;

ofstream out_file;
out_file.open(of1.c_str());
while (!in1.eof())
{
in13.open("detector1.txt");
in14.open("detector2.txt");
in15.open("detector3.txt");
in16.open("detector4.txt");
in17.open("detector5.txt");
in18.open("detector6.txt");
in19.open("detector7.txt");
in20.open("detector8.txt");
in21.open("detector9.txt");
in22.open("detector10.txt");
in23.open("detector11.txt");
in24.open("detector12.txt");
k=10000;

in1 >m1;
in2 >m2;
in3 >m3;
in4 >m4;
in5 >m5;
in6 >m6;
in7 >m7;
in8 >m8;
in9 >m9;
in10 >m10;
in11 >m11;
in12 >m12;

for (j=0; j<=18500;j++)
{
in13>>x[j] >>y[j] >>z[j] >>c1;
in14>>c2;
in15>>c3;
in16>>c4;
in17>>c5;
in18>>c6;
in19>>c7;
in20>>c8;
in21>>c9;
in22>>c10;
in23>>c11;
in24>>c12;
f=pow((c1-m1),2)/c1 + pow((c2-m2),2)/c2 + pow((c3-m3),2)/c3 +
pow((c4-m4),2)/c4 + pow((c5-m5),2)/c5 + pow((c6-m6),2)/c6 +
pow((c7-m7),2)/c7 + pow((c8-m8),2)/c8 + pow((c9-m9),2)/c9 +
pow((c10-m10),2)/c10 + pow((c11-m11),2)/c11 + pow((c12-m12),2)/c12;

if (f<k)
{
k=f;
a=x[j];
b=y[j];
c=z[j];
}
}
j=0;
cout <<a<<b<<c<<" "<<k<<endl;
out_file<<"\n"<<a<<" "<<b<<" "<<c<<endl;
in13.close();
in14.close();
in15.close();
in16.close();
in17.close();
in18.close();
in19.close();
in20.close();
in21.close();
in22.close();
in23.close();
in24.close();

}
//getch();
}

Nov 13 '06 #1
2 2069
Hello,
I have a small program to read data from some data files , in it I use
string types to build the data file name but when I try to compile it I
get: (see code below error)
root@rob-laptop:/home/rob/pankaj# gcc ptcllocate.cpp
compile with g++, not gcc:
# g++ ptcllocate.cpp

.... and yes, I am sure you can get a more compact program by using
arrays and for() loops for instance.

Cheers,
Loic.

Nov 13 '06 #2

merrittr wrote:
I have a small program to read data from some data files , in it I use
string types to build the data file name but when I try to compile it I
get: (see code below error)
root@rob-laptop:/home/rob/pankaj# gcc ptcllocate.cpp
/tmp/ccg9j6Mi.o: In function `main':ptcllocate.cpp:(.text+0x99):
undefined reference to `std::allocator<char>::allocator()'
:ptcllocate.cpp:(.text+0xb9): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::basic_string(char const*, std::allocator<charconst&)'
:ptcllocate.cpp:(.text+0xc7): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0xd5): undefined reference to
`std::allocator<char>::allocator()'
:ptcllocate.cpp:(.text+0xf5): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::basic_string(char const*, std::allocator<charconst&)'
:ptcllocate.cpp:(.text+0x111): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x133): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x141): undefined reference to
`std::allocator<char>::allocator()'
:ptcllocate.cpp:(.text+0x161): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::basic_string(char const*, std::allocator<charconst&)'
:ptcllocate.cpp:(.text+0x17d): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x196): undefined reference to
`std::allocator<char>::~allocator()'
:ptcllocate.cpp:(.text+0x1d6): undefined reference to
`std::allocator<char>::~allocator()'


any Idea what I am missing?
code:
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <math.h>
#include <iomanip>
#include <string>

int main(int argc,char *argv[])
{
using namespace std;
int i,j;
long double
x[19500],y[19500],z[19500],c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,m1,m2,m3,m 4,m5,m6,m7,m8,m9,m10,m11,m12,a=0,b=0,c=0,f=0,k;
long double l, m, n, o ;

string beginning = "count";
string endding = ".txt";
string outf = "data";
string cf1(beginning + argv[0] + endding);
string cf2(beginning + argv[1] + endding);
string cf3(beginning + argv[2] + endding);
string cf4(beginning + argv[3] + endding);
string cf5(beginning + argv[4] + endding);
string cf6(beginning + argv[5] + endding);
string cf7(beginning + argv[6] + endding);
string cf8(beginning + argv[7] + endding);
string cf9(beginning + argv[8] + endding);
string cf10(beginning + argv[9] + endding);
string cf11(beginning + argv[10] + endding);
string cf12(beginning + argv[11] + endding);
string of1(outf + argv[1] + "_" + argv[11] + endding);
ifstream in1(cf1.c_str());
ifstream in2(cf2.c_str());
ifstream in3(cf3.c_str());
ifstream in4(cf4.c_str());
ifstream in5(cf5.c_str());
ifstream in6(cf6.c_str());
ifstream in7(cf7.c_str());
ifstream in8(cf8.c_str());
ifstream in9(cf9.c_str());
ifstream in10(cf10.c_str());
ifstream in11(cf11.c_str());
ifstream in12(cf12.c_str());
ifstream in13;
ifstream in14;
ifstream in15;
ifstream in16;
ifstream in17;
ifstream in18;
ifstream in19;
ifstream in20;
ifstream in21;
ifstream in22;
ifstream in23;
ifstream in24;

ofstream out_file;
out_file.open(of1.c_str());
while (!in1.eof())
{
in13.open("detector1.txt");
in14.open("detector2.txt");
in15.open("detector3.txt");
in16.open("detector4.txt");
in17.open("detector5.txt");
in18.open("detector6.txt");
in19.open("detector7.txt");
in20.open("detector8.txt");
in21.open("detector9.txt");
in22.open("detector10.txt");
in23.open("detector11.txt");
in24.open("detector12.txt");
k=10000;

in1 >m1;
in2 >m2;
in3 >m3;
in4 >m4;
in5 >m5;
in6 >m6;
in7 >m7;
in8 >m8;
in9 >m9;
in10 >m10;
in11 >m11;
in12 >m12;

for (j=0; j<=18500;j++)
{
in13>>x[j] >>y[j] >>z[j] >>c1;
in14>>c2;
in15>>c3;
in16>>c4;
in17>>c5;
in18>>c6;
in19>>c7;
in20>>c8;
in21>>c9;
in22>>c10;
in23>>c11;
in24>>c12;
f=pow((c1-m1),2)/c1 + pow((c2-m2),2)/c2 + pow((c3-m3),2)/c3 +
pow((c4-m4),2)/c4 + pow((c5-m5),2)/c5 + pow((c6-m6),2)/c6 +
pow((c7-m7),2)/c7 + pow((c8-m8),2)/c8 + pow((c9-m9),2)/c9 +
pow((c10-m10),2)/c10 + pow((c11-m11),2)/c11 + pow((c12-m12),2)/c12;

if (f<k)
{
k=f;
a=x[j];
b=y[j];
c=z[j];
}
}
j=0;
cout <<a<<b<<c<<" "<<k<<endl;
out_file<<"\n"<<a<<" "<<b<<" "<<c<<endl;
in13.close();
in14.close();
in15.close();
in16.close();
in17.close();
in18.close();
in19.close();
in20.close();
in21.close();
in22.close();
in23.close();
in24.close();

}
//getch();
}
With std::vector and a simple function to parse arguements, another to
read file input, your 131 lines would probably be reduced to a couple
dozen lines. Why not try reading one parameter, open one file using one
std::ifstream, do some error checking and then output to one file. One
leggo brick at a time. Code like you had 1 million of the above to
make. Once you prove one works, you can make a gazillion of them.

note:
std::vector< std::string vs(100000); // makes 100.000 strings
instantly

yes, man, one line of code made 100,000 strings.

beats doing:
std::string s0;
std::string s1;
and so on...

Nov 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ram Sundaram | last post by:
Hi, I am trying to port some linux code to windows under Visual studio. The regex package currently used is the GNU regex package which calls for <strings.h>. This is not found in visual studio....
6
by: Joachim | last post by:
I made some project changes (which seems it doesn't help if I undo) which have created compilation error: " Server Error in '/PCSWebApp1' Application....
0
by: Jie | last post by:
Does anyone know why I keep having the following error. I have to rebuild the solution every time I run it in design mode. thanks jie Server Error in '/ReapPortal' Application....
2
by: VB Programmer | last post by:
I created a ASP.NET app locally and it works great. Uploaded it to my server and I get this error when trying to view a page. Any ideas? Server Error in '/earlyalert3' Application....
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
6
by: chandan | last post by:
I am looking for a small program or two that allows me to see what is being sent to a device on the serial port, and the response coming in the serial port from the device. When I have COM1...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
3
by: psroga | last post by:
Can anyone look at this code and let me know why pthread_mutex_unlock and pthread_mutex_lock are giving me the "phtread_mutex_unlock" was not defined in this scope error. I am compiling the code...
0
by: [david] | last post by:
http://pyserial.sourceforge.net/ "port numbering starts at zero, no need to know the port name in the user program" But the implementation in SerialWin32 is just (Portnum +1)
7
by: siocodes | last post by:
I know I am so close on this, but I cannot see what the syntax fix is. I am sending two e-mails via one asp page; one to the gift giver and one to the recipient...I originally had the message text in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.