President Obama told an audience at the Meyerson Symphony Center in Dallas on Tuesday that it was easier for teenagers to obtain a gun than a book.

The president, in Texas to pay respect to the five officers who died July 7 when 25-year-old Micah Xavier Johnson attacked during a Black Lives Matter protest, said that “the overwhelming majority of police officers do an incredibly hard and dangerous job fairly and professional,” but added that racial bias exists against minorities. He then went on to criticize the accessibility of guns on city streets.

“It is easier for a teenager to get his hands on a Glock than a computer or even a book,” Mr. Obama said. “And then we tell the police, ‘You’re a social worker. You’re the parent. You’re the teacher. You’re the drug counselor.’ We tell them to keep those neighborhoods in check at all costs and do so without causing any political blowback or inconvenience.”

Buzzfeed News, which live-tweeted the president’s remarks, was inundated with responses to the “Glock” remark.

“I hate going to Barnes and Noble and filling out a background check for books,” wrote one reader.

“Why would the president publicly state an easily verifiable lie? What’s the gain?” another asked.

“I didn’t know you could pick up a gun at the library,” one added.

Mr. Obama was also joined by former President George W. Bush, who said, “at times it feels like the forces pulling us apart are stronger than the forces binding us together. Argument turns too easily into animosity. We do not want the unity of grief nor do we want the unity of fear. We want the unity of hope, affection and high purpose.”

The president was scheduled to meet with families of the fallen officers after the ceremony.

The slain men were Lorne Ahrens, 48, Michael Krol, 40, Mike Smith, 55, Brent Thomson, 43, and Patrick Zamarripa, 32.