Programming in C with Ubuntu

Posted: August 23, 2012 in turtorial
Tags: , , ,

C is the programming language most frequently associated with UNIX-like operating systems such as Linux or BSD. Since the 1970s, the bulk of the UNIX operating system and its applications have been written in C. Because the C language doesn’t directly rely on any specific hardware architecture, UNIX was one of the first portable operating systems. In other words, the majority of the code that makes up UNIX doesn’t know and doesn’t care which computer it is actually running on.Machine-specific features are isolated in a few modules within the UNIX kernel, which makes it easy for you to modify them when you are porting to different hardware architectures.

C++ extends the capabilities of C by providing the necessary features for object-oriented design and code. C++ also provides some features, such as the capability to associate functions with data structures that do not require the use of class-based object-oriented techniques. For these reasons, the C++ language enables existing UNIX programs to migrate toward the adoption of object orientation over time.Support for C++ programming is provided by gcc, which you run with the name g++when you are compiling C++ code.

You could use make to compile, build, and install a software package, using a simple command like this:

santos@santos:~$ sudo make install

You can use the default makefile (usually called Makefile, with a capital M), or you can use make’s -f option to specify any makefile, such as MyMakeFile, like this:

santos@santos:~$ sudo make -f MyMakeFile

Other options might be available, depending on the contents of your makefile. You may have a source file named hi.c and just run make hi, where make figures out what to do automatically to build the final executable. See make’s built-in rules with make -p.

Using the makefile from the preceding example, you can build a program like this:

santos@santos:~$ sudo make

To build a specified component of a makefile, you can use a target definition on the command line. To build just the program, you use make with the skel target, like this:

santos@santos:~$ sudo make skel

If you make any changes to any element of a target object, such as a source code file, make rebuilds the target automatically. This feature is part of the convenience of usingmake to manage a development project. To build and install a program in one step, you can specify the target of install like this:

santos@santos:~$ sudo make install

The make command is only one of several programming automation utilities included with Ubuntu. There are others, such as automake, and one of the newer tools, autoconf, which builds shell scripts that can be used to configure program source code packages.Many Linux commands and graphical clients for X downloaded in source code forminclude configure scripts. To configure the source package, build the software, and then install the new program, the root user might use the script like this

santos@santos:~$ ./configure ; make ; sudo make install

Although creating the dependency-checking configure script can be done manually, you can easily overcome any complex dependencies by using a graphical project development tool such as KDEs KDevelop or GNOME’s Glade.

Posted: June 23, 2011 in breaking news


NEW YORK   News last week that an arm of the World Health Organization said cellphones might raise the risk of brain cancer has been greeted by Americans mostly with a shrug of the shoulder – one that’s pinning a cellphone to the ear.

Google searches for “cancer” and “cellphones” spiked this week. And some people vowed to get headsets to shield themselves from radiation. But most seemed to either dismiss the warning as too vague, or reason that if the most useful device in modern life poses a serious health risk, then so be it.

“I was watching the news about it, and I thought, `I’m already screwed because I’ve been talking on the phone for seven years,'” said Genevieve Chamorro, a 31-year-old New Yorker who was shopping for a phone.

John Gottani, a manager at a cellphone store in New York, said he’s been selling phones for six years and has never heard anyone ask if they cause cancer. The only things customers really care about, Gottani said, are “if it works, and if it texts.”

The International Agency for Research on Cancer reviewed dozens of published studies on cellphones and cancer before classifying cellphones as “possibly carcinogenic” on Tuesday. It’s a risk category that includes night-shift work, engine exhaust and coffee.

Studies haven’t been able to rule out a link between cellphones and cancer. But experts say that if there is a link, it’s unlikely to be strong. Cellphones emit weak radio waves, which, under the conventional understanding of physics, can’t wreak the same sort of cellular changes that sunlight and radioactivity can.

A common tip offered to those who want to reduce their exposure to cellphone radiation is to use a headset. Even wireless Bluetooth headsets reduce radiation exposure. Though they emit radio signals of their own, they’re much weaker than cellphone signals.

But there seems to be little rush to get Bluetooth headsets. They’ve been declining in popularity for at least four years, according to research firm Strategy Analytics. It’s also found that most headset owners don’t intend to replace the one they have when it wears out.

According to Strategy Analytics analyst Chris Schreiner, the main reason is that when you’re wearing a Bluetooth headset, you look like a person who’s wearing a Bluetooth headset.

“Style has always been a huge issue in terms of Bluetooth headsets,” Schreiner said.

On Twitter this week, the most common posts mentioning “headset” and “cancer” have been repeats of a joke from humor site “I can’t decide between being seen wearing a Bluetooth headset or just getting brain cancer.”

Cellphones differ in how much radiation they emit. Proposals in a few states would force cellphone stores to display these radiation ratings.

But CTIA-The Wireless Association, the cellphone industry trade group, is fighting these moves. It says there’s no evidence the measured ratings have any correlation with risks. And cellphone manufacturers and carriers are showing no sign of breaking ranks with each other to use the ratings to their advantage – for instance, by touting “low-radiation phones.”

Spokesman John Walls said CTIA wouldn’t fight a manufacturer that wanted to market a “low-radiation phone.” But claiming a phone to be safer than any other would cross the line, he said.

“They’re all deemed safe by science,” Walls said.

Americans on average talk about 700 minutes a month on their cellphones, making them some of the most talkative people in the world, well ahead of Europeans.

In San Francisco, Chuck Luter, 42, said he doesn’t plan to change his habits as a result of the radiation warning. When the advertising-shoot prop stylist talks on his Sidekick phone, he usually uses the speakerphone, so it’s not close to his head.

And in any case, he texts more than he talks. Besides, he added, there are few alternatives to owning a cellphone.

“What are the other options? To not have one? To try to keep it all in your head? There are so many bad things for you – just add this to the pile.”

Statement of Human Rights First
House Judiciary Subcommittee on Immigration Policy and Enforcement
Hearing on H.R.1932, the “Keep Our Communities Safe Act of 2011”
May 24, 2011

Human Rights First urges Congress to reject amendments to the Immigration and Nationality
Act (INA) that would broaden the scope of the Department of Homeland Security’s (DHS)
already vast power to detain asylum seekers and other immigrants in removal proceedings and
limit the already inadequate safeguards presently in place to protect asylum seekers and other
immigrants against arbitrary or prolonged detention. While this proposed legislation couches
itself as providing for the detention of dangerous aliens and as a measure to “keep our
communities safe,” its adverse impact would be felt by a great many persons who do not
warrant that description and whose detention is unconnected to community safety. Congress
should recognize the effect that any such amendments would have on asylum seekers and
other vulnerable immigrants.

Since 1978, Human Rights First has worked to protect and promote fundamental human rights
and to ensure protection of the rights of refugees. Human Rights First operates one of the
country’s largest pro bono asylum representation programs. Our volunteer lawyers have
helped victims of political, religious, and other persecution from over 80 countries—including
Burma, China, Colombia, Congo (DRC), Iraq, and Zimbabwe—gain protection from persecution
through asylum in this country. Because of the inadequate due process protections that
currently exist in the immigration detention system, many of these refugees have been held in
U.S. immigration detention centers for months—some for years—even after they have been
found by the government to have a credible fear of persecution and when there is no reason to
believe they pose a risk of flight or danger to others.

In April 2009, Human Rights First released a report, U.S. Detention of Asylum Seekers: Seeking
Protection, Finding Prison, in which we found that between 2003 and 2009, DHS detained over
48,000 asylum seekers in jails and jail-like facilities at an estimated cost of over $300 million.

Refugees who have been forced to languish for months or years in jails and jail-like facilities

before being granted asylum in the United States include:

• A Burmese school teacher, who supports democracy and was jailed for two years by the
Burmese military regime, fled to the United States for protection and was detained by
DHS for 7 months in a Texas immigration jail before being granted asylum;

• A Baptist Chin woman, who fled Burma for political and religious reasons, was detained
by DHS for 24 months before being granted asylum, even though she had proof of her
identity and family in the United States and the U.S. government agreed that she would
be subjected to torture if returned to Burma. Her detention cost U.S. taxpayers more
than $90,000;

• An Afghan teacher who was threatened by the Taliban, in part due to his affiliations
with U.S. armed forces, spent 20 months in detention at three county jails in Illinois and
Wisconsin, despite having letters of support from U.S. government officials who knew
him because he taught at an educational institution sponsored by U.S. and NATO forces
in Afghanistan. He was eventually released on an ankle monitor and granted asylum.

• A Tibetan man, who was tortured by Chinese authorities and detained for more than a
year after putting up pro-Tibetan independence posters, was held for 11 months at a
New Jersey facility—at a cost of over $53,000—before being granted asylum;

• An Ethiopian refugee was detained at the Pearsall Detention Center in Texas after he
crossed the Mexican border in order to seek asylum in the United States. In Ethiopia, he
had been tortured and detained after he was falsely accused of taking part in an anti-
government protest. He remained in DHS detention for over 5 months and was released
only after he was granted asylum;

• A Colombian refugee, who had been jailed, beaten, and tortured for participating in a
political demonstration in Colombia, was detained by DHS in Arizona for 14 months,
including for over 8 months after an Immigration Judge had ruled that he was eligible
for asylum; and

• A Sri Lankan fisherman, who was a victim of kidnapping by the Liberation Tigers of Tamil
Eelam (LTTE), was detained in an immigration detention facility in Elizabeth, NJ for 30
months before being released on a highly restrictive ankle bracelet. After several years,
he was eventually granted asylum.

These asylum seekers – and thousands of others like them – were held at the American
taxpayer’s expense for months and sometimes years because the system lacks basic due
process safeguards. Under current law, refugees arriving at U.S. borders or ports of entry

seeking asylum are subject upon arrival to mandatory detention under the “expedited removal”
provisions of U.S. immigration law. The initial determination to detain an asylum seeker is not
based on an individualized assessment of factors such as whether the person poses a security
threat or a risk of flight. Rather, it is a blanket determination based on whether a person
possesses valid travel documents or expresses an intention to apply for asylum upon arrival in
the United States.
If the person is found by DHS to have a “credible fear of persecution,” DHS’s Immigration &
Customs Enforcement (ICE)—which is the detaining authority—can assess whether to release
the asylum seeker on parole. But if ICE denies release, that decision cannot be appealed, even
to an immigration judge, under Department of Justice regulations that preclude immigration
judges from reviewing the detention of “arriving aliens,” a category that includes asylum
seekers who request refugee protection at U.S. airports and borders. Reforms to ICE’s own
parole procedures that went into effect in January 2010, while a welcome improvement, did
not address the lack of prompt independent court review of ICE’s detention decisions. This lack
of review is inconsistent with the treaty obligations of the United States under the 1967 U.N.
Protocol Relating to the Status of Refugees and the International Covenant on Civil and Political
Rights (ICCPR).

DHS regulations set no limit on the length of time an asylum seeker may be detained while his
or her asylum proceedings are pending, and there are currently limited procedures in place to
review the detention of asylum seekers and other vulnerable immigrants, arriving aliens or
otherwise, who are facing a risk of prolonged detention while they wait for a final decision on
their cases. Asylum seekers who have suffered from prolonged detention during removal
proceedings have included refugees granted asylum who were detained further while DHS
appealed the decisions in their favor. Improving the immigration detention system so as to
make it both more cost-effective and more consistent with the human rights requires
strengthening the protections available under current law, not curtailing them.
Beyond the considerable fiscal cost, the unnecessary detention of asylum seekers takes a
lasting emotional toll on them and their families. It also makes it more difficult for asylum

Article 9(4) of the ICCPR provides that “[a]nyone who is deprived of his liberty by arrest or detention shall be
entitled to take proceedings before a court, in order that the court may decide without delay on the lawfulness of
his detention and order his release if the detention is not lawful.” Article 31 of the 1951 U.N. Convention Relating
to the Status of Refugees exempts refugees from being punished because of their illegal entry into or presence in
the country of refugee and also provides that states shall not restrict the movements of refugees more than is
“necessary.” By ratifying the 1967 Protocol, the United States bound itself to the substantive provisions of the
1951 Refugee Convention. The Executive Committee of the U.N. High Commissioner for Refugees (UNHCR), of
which the United States is a member, has recommended that the detention of asylum seekers “be subject to
judicial or administrative review,” and UNHCR guidelines on the detention of asylum seekers make clear that there
should be “automatic review before a judicial or administrative body independent of the detaining authorities.”
UNHCR Exec. Comm., Detention of Refugees and Asylum-Seekers, Conclusion No. 44 (XXXVII), ¶ e (Oct. 13, 1986);
UNHCR, Revised Guidelines on Applicable Criteria and Standards Relating to the Detention of Asylum Seekers,
Guideline 5(iii) (Feb. 1999).

seekers, particularly the increasing proportion now detained in remote locations, to obtain legal
help or to assemble the evidence necessary to prove their cases in immigration court.
Human Rights First cautions Congress against expanding DHS’s detention authority, limiting
access to bond hearings by immigration judges, expanding any categories of mandatory
detention, and/or limiting judicial review. As a nation committed to the rule of law, the United
States must guarantee basic due process protections designed to prevent asylum seekers and
other immigrants from being subjected to arbitrary and prolonged detention. Efforts to strip
these basic protections run contrary to the fundamental principles of liberty and freedom that
have made this country a beacon of hope for the persecuted around the world.

CHICAGO (Reuters) – Early studies suggest an experimental Alzheimer’s drug attacks free-floating bits of a protein called beta amyloid, a sign the drug may fight what some researchers consider to be the disease’s chief culprit.Bapineuzumab, being developed by Pfizer Inc and Johnson & Johnson, is among the most advanced in the search for effective treatments for Alzheimer’s, a fatal brain-wasting disease that affects 26 million people globally.Current drugs only address symptoms, and recent attempts by Eli Lilly and Co and Medivation Inc for a meaningful treatment have largely failed.

A small brain imaging study last year showed bapineuzumab was able to shrink solid clumps of beta amyloid in the brain by 25 percent in 28 patients.But several recent studies in mice and rats suggest that the much smaller floating, or soluble, pieces of beta amyloid found in cerebrospinal fluid – the clear, watery substance that bathes the brain and spinal cord — are the real bad actors in Alzheimer’s disease.

That has raised questions about whether bapineuzumab — an engineered immune-system molecule called a monoclonal antibody — is targeting the wrong thing.To study this, researchers at J&J did a series of studies in mice and cells. They suggested that the drug not only binds to soluble beta amyloid, but also may neutralize some of the protein’s ability to harm brain cells.

“We can feel very comfortable that it is engaging both soluble and insoluble forms,” said Gene Kinney, head of research for J&J’s Janssen Alzheimer Immunotherapy, who worked on the studies presented at an Alzheimer’s and Parkinson’s disease meeting in Barcelona on Thursday.In one study, the team showed that injecting the drug in mice bred to develop amyloid plaques helped them overcome learning problems.

“What it suggests is you’ve got an antibody approach that can interact with both forms of amyloid,” Kinney told Reuters in a telephone interview.Kinney is not ready to concede that soluble amyloid is more important than insoluble amyloid.

“In our minds there is significant evidence that both the soluble and insoluble forms contribute to the disease, and it is likely an ongoing process that occurs as patients progress,” he said.Bapineuzumab has had mixed results in a mid-stage clinical trials in people and the drug is now being tested in late-stage studies that aim to show whether it can prevent reasoning problems in people with mild to moderate Alzheimer’s.


u2NEW YORK  U2’s Bono is expected to attend Tuesday night’s performance of “Spider-Man: Turn Off the Dark” as speculation swirls over whether the troubled Broadway show’s opening night will be delayed again.Bono, who wrote the music and lyrics with bandmate The Edge, hasn’t been able to critique the show since he stopped in to check on its progress in mid-January.

The $65 million show has been delayed five times and is supposed to open on March 15. Despite its woes, it is among the highest earners each week on Broadway.Rick Miramontez, a show spokesman, said Tuesday that any decision about the future of “Spider-Man” would include producers and the creative team, led by director Julie Taymor.Says Miramontez: “All decisions are made as a group.”(AP)

CARACAS,  Venezuelan President Hugo Chavez said Monday that he won’t condemn Libyan leader Moammar Gadhafi and he warned that the United States is preparing an invasion of the North African country to seize control of its oil reserves.”A campaign of lies is being spun together regarding Libya,” said Chavez, in a televised speech to a crowd of graduates who had just received diplomas from state universities. “I’m not going to condemn him. I’d be a coward to condemn someone who has been my friend.”

The U.S. government is behind the campaign to remove Gadhafi, he said.”The United States has already said it’s ready to invade Libya, don’t you see? And almost all the countries of Europe are condemning Libya … What do they want. They are rubbing their hands together. Oil is what’s important to them,” he said.Chavez noted that numerous countries have condemned Gadhafi for cracking down on Libyans who have risen up against him.”Maybe they have information that we don’t have,” he said.Chavez slammed the United States for moving naval and air forces closer to Libya amid active international discussions about imposing a no-fly zone over the country, and he warned that U.S. officials are preparing to invade Libya.

Chavez and Gadhafi, united in their mutual antagonism toward Washington, have forged close ties.Venezuela’s opposition has strongly criticized Chavez for his close relationship to Gadhafi. Earlier on Monday, a coalition of opposition parties warned that Chavez’s failure to take a stand against Gadhafi’s violent crackdown is smearing Venezuela’s reputation.

“By distancing himself from the numerous nations that condemn the criminal actions of the Libyan leader, Chavez makes our country out to be his defender and irresponsibly puts us alongside governments rejected by the international community,” the coalition said in a statement.Opposition politician Gustavo Azocar demanded that Chavez ask Gadhafi to return a replica of the sword that once belonged to 19th-century independence hero Simon Bolivar.

Azocar said in an e-mail sent to The Associated Press on Monday that Venezuela’s foreign minister, Nicolas Maduro, “should explain why the government gave the sword of the Liberator, Simon Bolivar, to an assassin like Gadhafi.”Chavez gave the sword to Gadhafi last year. The self-proclaimed socialist has scoffed at suggestions by his adversaries that protests similar to those sweeping the Middle East could occur in Venezuela.Venezuela and Libya are both major oil exporters. (AP)

ShakiraCAMBRIDGE, Mass. Colombian singer Shakira was honored Saturday by Harvard University for her artistic and humanitarian work. She later said some U.S. states’ proposed anti-immigrant legislation goes against her foundation’s efforts to provide education to poor people around the world.The Grammy Award-winning singer, however, said Latino immigrants in the U.S. facing various anti-immigrant bills will have “justice” as public awareness about their plight grows.

“Justice will come. I’m sure,” Shakira told The Associated Press after the award ceremony. “Wherever there is … a kid, who could be the son or the daughter of a Latino immigrant, who cannot attend a school in the United States of America, that kid should be a concern to all of us and our responsibility.”Shakira made the comments in an interview when asked about proposed measures in Arizona and elsewhere targeting illegal immigrants. A bill in Arizona, for example, would bar illegal immigrants from attending public schools, living in public housing or driving. Another bill seeks to deny citizenship to children born in the U.S. if their parents are illegal immigrants.

“I believe we should never think less of the Latino community because it’s a productive force in this country,” Shakira told the AP.The singer, born Shakira Isabel Mebarak Ripoll, was awarded the “2011 Artist of the Year” from the Harvard Foundation, the university’s center for intercultural arts and science initiatives.Foundation director S. Allen Counter said Shakira, who has sold more than 50 million albums worldwide, was honored for her “distinguished history of creativity,” as well as for her charitable contributions.Previous winners of the Harvard award include Sharon Stone, Will Smith, Jackie Chan and Herbie Hancock.Shakira said she was humbled by the award and the student performances at the ceremony.

“As I entered the premises today, I had to call my mom and say, ‘Hey mom. Guess what? I got into Harvard’,” said Shakira, who took a history class in 2008 at UCLA.After accepting the award, she challenged Harvard students to do more to improve education in developing countries. “Not everyone can study at Harvard University,” she said. “But everyone, wherever they live, whatever their background, deserves a chance to make the most of his or her potential” through education.She said that applied to poor children in Bangladesh or immigrants in the United States. “And as a child of the developing world, it is my duty to use this voice in every way I can to promote the message about the power of education to change lives,” she said.

Shakira founded the Barefoot Foundation at the age of 18 to provide education and nutrition to children in impoverished areas of Colombia. She also is a UNICEF Goodwill Ambassador.Howard Buffett, 56, son of billionaire investor Warren Buffett and board member of the Barefoot Foundation, said he and Shakira have plans to work on educational projects in parts of the world ravaged by war and natural disasters.”I think she brings credibility, particularly because of her background,” Buffett said. “She’s pretty focused on education.”(AP)


The regime of Col Muammar Gaddafi of Libya was on the verge of collapse on Monday night, but the dictator hit out at the “dogs” who claimed he had fled the country.

Muammar GaddafiAs the violence intensified and indiscriminate shootings were reported in Tripoli, Gaddafi appeared on state television early on Tuesday to deny “malicious reports” he had fled after several cities fell to opposition forces.Libyan air force jets launched bombing raids on military bases and, it was claimed, rebel areas in a final attempt to reassert control.Two colonels in the air force flew their jets to Malta, saying they had refused orders to fire on protesters in the second city Benghazi and wanted to seek asylum.

Senior regime figures, including his public security minister, justice minister and seven ambassadors around the world, also deserted Col Gaddafi. Libya’s deputy ambassador to the UN, Ibrahim Omar al-Dabashi, described his leader’s actions as “genocide” and pleaded for international intervention.In his brief appearance on Libyan television, where he was filmed leaning out of the back of a car holding an umbrella, Gaddafi claimed he was still in Tripoli.


FirefightersNEW YORK  Officials say one person has died in a fire that ripped through a six-story New York City apartment building.A fire department spokesman says the body of a 64-year-old woman was found in the rubble after firefighters battled strong winds for several hours trying to extinguish the blaze. The victim’s name was not released.Officials say 20 firefighters were injured battling Saturday’s blaze in Brooklyn. None of the injuries are life-threatening. Four civilians suffered minor injuries. Seven people were treated at the scene.

Strong winds complicated firefighters’ efforts at the building on East 29th Street before the five-alarm fire was brought under control early Sunday.Over 200 firefighters were called to the scene.The building has about 70 apartments. The spokesman says a shelter for displaced residents has been set up at a nearby school.(AP)