President Donald Trump, on an unannounced visit to American military personnel in Iraq, said Wednesday he will do "whatever it takes" to secure border wall funding and attacked Democrats for blocking him.

"We need a wall," Trump said at the Al-Asad Air Base west of Baghdad. "We need safety for our country."

Presidents normally avoid partisan fights in military settings as part of a bipartisan tradition of keeping national security institutions separate from politics. Trump, who has frequently disregarded this norm, used his speech to soldiers to attack Democrats over the standoff, saying they only opposed a wall "because I want it."

"I think I'll say, 'I don't want the wall,' and then they're gonna give it to me," he said.

With little apparent movement in the White House or Congress toward a deal to end the ongoing government shutdown, Rep. Mark Meadows, R-N.C., also said on Wednesday that he had spoken to Trump and saw no sign he would back off his demand to fund a wall.

"I can tell you that if they believe that this president is going to yield on this particular issue, they're misreading him, they're misreading the American people because he's intent on making sure that (he) not only follows through with this commitment to the American people, but that he makes sure that our borders are secure," Meadows, who chairs the influential conservative House Freedom Caucus, said in an appearance on CNN.

He added, "I don't think there's any situation where the president should give up on that demand."

At the same time, Meadows said Trump has asked "rank-and-file" Republicans to reach out to Democrats on their own in hope of finding a compromise.

"I can tell you that the president is very firm and he's resolved that we need to secure our border, and he is encouraging me and others to enter into discussions with Democrats," Meadows said in an appearance on CNN.

Democrats are set to take over the House on Jan. 3 after winning 40 seats and a majority in the midterm elections, giving Republican members like Meadows diminished leverage over the outcome. House Minority Leader and Speaker nominee Nancy Pelosi and Senate Minority Leader Chuck Schumer have insisted that they will not sign onto a funding bill that includes money to build a new stretch of wall along the Mexican border.

"I think...part of the reason why you don't see a tremendous amount of freneticism on the Hill is because both Democrats and Republicans know full well: Donald Trump lost this fight before it started and they're just waiting for him to capitulate," Philippe Reines, a former aide to Hillary Clinton, said on MSNBC on Wednesday.